<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP
           , NoImplicitPrelude
           , RecordWildCards
           , NondecreasingIndentation
  #-}</span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-unused-matches #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Module      :  GHC.IO.Handle</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 1994-2009</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- Portability :  non-portable</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- External API for GHC's Handle implementation</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.IO.Handle</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-24"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier">Handle</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferMode"><span class="hs-identifier">BufferMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.Internals.html#mkFileHandle"><span class="hs-identifier">mkFileHandle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Internals.html#mkDuplexHandle"><span class="hs-identifier">mkDuplexHandle</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.html#hFileSize"><span class="hs-identifier">hFileSize</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hSetFileSize"><span class="hs-identifier">hSetFileSize</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hIsEOF"><span class="hs-identifier">hIsEOF</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#isEOF"><span class="hs-identifier">isEOF</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hLookAhead"><span class="hs-identifier">hLookAhead</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.html#hSetBuffering"><span class="hs-identifier">hSetBuffering</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hSetBinaryMode"><span class="hs-identifier">hSetBinaryMode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hSetEncoding"><span class="hs-identifier">hSetEncoding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hGetEncoding"><span class="hs-identifier">hGetEncoding</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.html#hFlush"><span class="hs-identifier">hFlush</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hFlushAll"><span class="hs-identifier">hFlushAll</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hDuplicate"><span class="hs-identifier">hDuplicate</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hDuplicateTo"><span class="hs-identifier">hDuplicateTo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.html#hClose"><span class="hs-identifier">hClose</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Internals.html#hClose_help"><span class="hs-identifier">hClose_help</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.Lock.Common.html#LockMode"><span class="hs-identifier">LockMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Lock.html#hLock"><span class="hs-identifier">hLock</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Lock.html#hTryLock"><span class="hs-identifier">hTryLock</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosition"><span class="hs-identifier">HandlePosition</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier">HandlePosn</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hGetPosn"><span class="hs-identifier">hGetPosn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hSetPosn"><span class="hs-identifier">hSetPosn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>   </span><span class="annot"><a href="GHC.IO.Device.html#SeekMode"><span class="hs-identifier">SeekMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hSeek"><span class="hs-identifier">hSeek</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hTell"><span class="hs-identifier">hTell</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.html#hIsOpen"><span class="hs-identifier">hIsOpen</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hIsClosed"><span class="hs-identifier">hIsClosed</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hIsReadable"><span class="hs-identifier">hIsReadable</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hIsWritable"><span class="hs-identifier">hIsWritable</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hGetBuffering"><span class="hs-identifier">hGetBuffering</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hIsSeekable"><span class="hs-identifier">hIsSeekable</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.html#hSetEcho"><span class="hs-identifier">hSetEcho</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hGetEcho"><span class="hs-identifier">hGetEcho</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#hIsTerminalDevice"><span class="hs-identifier">hIsTerminalDevice</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.html#hSetNewlineMode"><span class="hs-identifier">hSetNewlineMode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Newline"><span class="hs-identifier">Newline</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier">NewlineMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#nativeNewline"><span class="hs-identifier">nativeNewline</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.Types.html#noNewlineTranslation"><span class="hs-identifier">noNewlineTranslation</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#universalNewlineMode"><span class="hs-identifier">universalNewlineMode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#nativeNewlineMode"><span class="hs-identifier">nativeNewlineMode</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.html#hShow"><span class="hs-identifier">hShow</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-47"></span><span>
</span><span id="line-48"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hWaitForInput"><span class="hs-identifier">hWaitForInput</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hGetChar"><span class="hs-identifier">hGetChar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hGetLine"><span class="hs-identifier">hGetLine</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hGetContents"><span class="hs-identifier">hGetContents</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hGetContents%27"><span class="hs-identifier">hGetContents'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hPutChar"><span class="hs-identifier">hPutChar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hPutStr"><span class="hs-identifier">hPutStr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span>   </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hGetBuf"><span class="hs-identifier">hGetBuf</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hGetBufNonBlocking"><span class="hs-identifier">hGetBufNonBlocking</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier">hPutBuf</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Text.html#hPutBufNonBlocking"><span class="hs-identifier">hPutBufNonBlocking</span></a></span><span>
</span><span id="line-51"></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.html"><span class="hs-identifier">GHC.IO</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Exception.html"><span class="hs-identifier">GHC.IO.Exception</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html"><span class="hs-identifier">GHC.IO.Encoding</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html"><span class="hs-identifier">GHC.IO.Buffer</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.BufferedIO.html"><span class="hs-identifier">GHC.IO.BufferedIO</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.IO.BufferedIO.html#BufferedIO"><span class="hs-identifier">BufferedIO</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Device.html"><span class="hs-identifier">GHC.IO.Device</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">IODevice</span></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.StdHandles.html"><span class="hs-identifier">GHC.IO.StdHandles</span></a></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.SubSystem.html"><span class="hs-identifier">GHC.IO.SubSystem</span></a></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Lock.html"><span class="hs-identifier">GHC.IO.Handle.Lock</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html"><span class="hs-identifier">GHC.IO.Handle.Types</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Internals.html"><span class="hs-identifier">GHC.IO.Handle.Internals</span></a></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Text.html"><span class="hs-identifier">GHC.IO.Handle.Text</span></a></span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.IO.BufferedIO.html"><span class="hs-identifier">GHC.IO.BufferedIO</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Buffered</span></span><span>
</span><span id="line-66"></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Exception.html"><span class="hs-identifier">GHC.Exception</span></a></span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.MVar.html"><span class="hs-identifier">GHC.MVar</span></a></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IORef.html"><span class="hs-identifier">GHC.IORef</span></a></span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Show.html"><span class="hs-identifier">GHC.Show</span></a></span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Num.html"><span class="hs-identifier">GHC.Num</span></a></span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Real.html"><span class="hs-identifier">GHC.Real</span></a></span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Maybe.html"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Typeable.html"><span class="hs-identifier">Data.Typeable</span></a></span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-78"></span><span class="hs-comment">-- Closing a handle</span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span class="hs-comment">-- | Computation 'hClose' @hdl@ makes handle @hdl@ closed.  Before the</span><span>
</span><span id="line-81"></span><span class="hs-comment">-- computation finishes, if @hdl@ is writable its buffer is flushed as</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- for 'hFlush'.</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- Performing 'hClose' on a handle that has already been closed has no effect;</span><span>
</span><span id="line-84"></span><span class="hs-comment">-- doing so is not an error.  All other operations on a closed handle will fail.</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- If 'hClose' fails for any reason, any further operations (apart from</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- 'hClose') on the handle will still fail as if @hdl@ had been successfully</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- closed.</span><span>
</span><span id="line-88"></span><span>
</span><span id="line-89"></span><span class="annot"><a href="GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-type">hClose</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span id="hClose"><span class="annot"><span class="annottext">hClose :: Handle -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var hs-var">hClose</span></a></span></span><span> </span><span id="local-6989586621679556282"><span class="annot"><span class="annottext">h :: Handle
</span><a href="#local-6989586621679556282"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679556280"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679556280"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-91"></span><span>  </span><span id="local-6989586621679556279"><span class="annot"><span class="annottext">Maybe SomeException
</span><a href="#local-6989586621679556279"><span class="hs-identifier hs-var">mb_exc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; MVar Handle__ -&gt; IO (Maybe SomeException)
</span><a href="GHC.IO.Handle.html#hClose%27"><span class="hs-identifier hs-var">hClose'</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556282"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679556280"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-92"></span><span>  </span><span class="annot"><span class="annottext">Maybe SomeException -&gt; Handle -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hClose_maybethrow"><span class="hs-identifier hs-var">hClose_maybethrow</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe SomeException
</span><a href="#local-6989586621679556279"><span class="hs-identifier hs-var">mb_exc</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556282"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-93"></span><span class="annot"><a href="GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span id="local-6989586621679556276"><span class="annot"><span class="annottext">h :: Handle
</span><a href="#local-6989586621679556276"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-type">DuplexHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679556274"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679556274"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621679556273"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679556273"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-94"></span><span>  </span><span id="local-6989586621679556272"><span class="annot"><span class="annottext">[Maybe SomeException]
</span><a href="#local-6989586621679556272"><span class="hs-identifier hs-var">excs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(MVar Handle__ -&gt; IO (Maybe SomeException))
-&gt; [MVar Handle__] -&gt; IO [Maybe SomeException]
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; [a] -&gt; m [b]
</span><a href="GHC.Base.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; MVar Handle__ -&gt; IO (Maybe SomeException)
</span><a href="GHC.IO.Handle.html#hClose%27"><span class="hs-identifier hs-var">hClose'</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556276"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679556274"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679556273"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-95"></span><span>  </span><span class="annot"><span class="annottext">Maybe SomeException -&gt; Handle -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hClose_maybethrow"><span class="hs-identifier hs-var">hClose_maybethrow</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SomeException] -&gt; Maybe SomeException
forall a. [a] -&gt; Maybe a
</span><a href="Data.Maybe.html#listToMaybe"><span class="hs-identifier hs-var">listToMaybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Maybe SomeException] -&gt; [SomeException]
forall a. [Maybe a] -&gt; [a]
</span><a href="Data.Maybe.html#catMaybes"><span class="hs-identifier hs-var">catMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe SomeException]
</span><a href="#local-6989586621679556272"><span class="hs-identifier hs-var">excs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556276"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-96"></span><span>
</span><span id="line-97"></span><span class="annot"><a href="GHC.IO.Handle.html#hClose_maybethrow"><span class="hs-identifier hs-type">hClose_maybethrow</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Exception.Type.html#SomeException"><span class="hs-identifier hs-type">SomeException</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-98"></span><span id="hClose_maybethrow"><span class="annot"><span class="annottext">hClose_maybethrow :: Maybe SomeException -&gt; Handle -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hClose_maybethrow"><span class="hs-identifier hs-var hs-var">hClose_maybethrow</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe SomeException
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span id="local-6989586621679556268"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556268"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-99"></span><span class="annot"><a href="GHC.IO.Handle.html#hClose_maybethrow"><span class="hs-identifier hs-var">hClose_maybethrow</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679556267"><span class="annot"><span class="annottext">SomeException
</span><a href="#local-6989586621679556267"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679556266"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556266"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SomeException -&gt; Handle -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hClose_rethrow"><span class="hs-identifier hs-var">hClose_rethrow</span></a></span><span> </span><span class="annot"><span class="annottext">SomeException
</span><a href="#local-6989586621679556267"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556266"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-100"></span><span>
</span><span id="line-101"></span><span class="annot"><a href="GHC.IO.Handle.html#hClose_rethrow"><span class="hs-identifier hs-type">hClose_rethrow</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Exception.Type.html#SomeException"><span class="hs-identifier hs-type">SomeException</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span id="hClose_rethrow"><span class="annot"><span class="annottext">hClose_rethrow :: SomeException -&gt; Handle -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hClose_rethrow"><span class="hs-identifier hs-var hs-var">hClose_rethrow</span></a></span></span><span> </span><span id="local-6989586621679556264"><span class="annot"><span class="annottext">SomeException
</span><a href="#local-6989586621679556264"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621679556263"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556263"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-103"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SomeException -&gt; Maybe IOException
forall e. Exception e =&gt; SomeException -&gt; Maybe e
</span><a href="GHC.Exception.Type.html#fromException"><span class="hs-identifier hs-var">fromException</span></a></span><span> </span><span class="annot"><span class="annottext">SomeException
</span><a href="#local-6989586621679556264"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-104"></span><span>    </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679556261"><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679556261"><span class="hs-identifier hs-var">ioe</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO ()
forall a. IOException -&gt; IO a
</span><a href="GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOException -&gt; FilePath -&gt; Handle -&gt; IOException
</span><a href="GHC.IO.Handle.Internals.html#augmentIOError"><span class="hs-identifier hs-var">augmentIOError</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679556261"><span class="hs-identifier hs-var">ioe</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hClose&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556263"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-105"></span><span>    </span><span class="annot"><span class="annottext">Maybe IOException
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SomeException -&gt; IO ()
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="GHC.IO.html#throwIO"><span class="hs-identifier hs-var">throwIO</span></a></span><span> </span><span class="annot"><span class="annottext">SomeException
</span><a href="#local-6989586621679556264"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-106"></span><span>
</span><span id="line-107"></span><span class="annot"><a href="GHC.IO.Handle.html#hClose%27"><span class="hs-identifier hs-type">hClose'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Exception.Type.html#SomeException"><span class="hs-identifier hs-type">SomeException</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-108"></span><span id="hClose%27"><span class="annot"><span class="annottext">hClose' :: Handle -&gt; MVar Handle__ -&gt; IO (Maybe SomeException)
</span><a href="GHC.IO.Handle.html#hClose%27"><span class="hs-identifier hs-var hs-var">hClose'</span></a></span></span><span> </span><span id="local-6989586621679556257"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556257"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679556256"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679556256"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; MVar Handle__
-&gt; (Handle__ -&gt; IO (Handle__, Maybe SomeException))
-&gt; IO (Maybe SomeException)
forall a.
FilePath
-&gt; Handle
-&gt; MVar Handle__
-&gt; (Handle__ -&gt; IO (Handle__, a))
-&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle%27"><span class="hs-identifier hs-var">withHandle'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hClose&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556257"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679556256"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO (Handle__, Maybe SomeException))
 -&gt; IO (Maybe SomeException))
-&gt; (Handle__ -&gt; IO (Handle__, Maybe SomeException))
-&gt; IO (Maybe SomeException)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO (Handle__, Maybe SomeException)
</span><a href="GHC.IO.Handle.Internals.html#hClose_help"><span class="hs-identifier hs-var">hClose_help</span></a></span><span>
</span><span id="line-109"></span><span>
</span><span id="line-110"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-111"></span><span class="hs-comment">-- Detecting and changing the size of a file</span><span>
</span><span id="line-112"></span><span>
</span><span id="line-113"></span><span class="hs-comment">-- | For a handle @hdl@ which attached to a physical file,</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- 'hFileSize' @hdl@ returns the size of that file in 8-bit bytes.</span><span>
</span><span id="line-115"></span><span>
</span><span id="line-116"></span><span class="annot"><a href="GHC.IO.Handle.html#hFileSize"><span class="hs-identifier hs-type">hFileSize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span>
</span><span id="line-117"></span><span id="hFileSize"><span class="annot"><span class="annottext">hFileSize :: Handle -&gt; IO Integer
</span><a href="GHC.IO.Handle.html#hFileSize"><span class="hs-identifier hs-var hs-var">hFileSize</span></a></span></span><span> </span><span id="local-6989586621679556254"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556254"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-118"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Integer) -&gt; IO Integer
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hFileSize&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556254"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Integer) -&gt; IO Integer)
-&gt; (Handle__ -&gt; IO Integer) -&gt; IO Integer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679556252"><span class="annot"><span class="annottext">handle_ :: Handle__
</span><a href="#local-6989586621679556252"><span class="hs-identifier hs-var">handle_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">haDevice :: ()
</span><a href="GHC.IO.Handle.Types.html#haDevice"><span class="hs-identifier hs-var">haDevice</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679556231"><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679556231"><span class="hs-identifier hs-var">dev</span></a></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-119"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679556252"><span class="hs-identifier hs-var">handle_</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-120"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Integer
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_closedHandle"><span class="hs-identifier hs-var">ioe_closedHandle</span></a></span><span>
</span><span id="line-121"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#SemiClosedHandle"><span class="hs-identifier hs-var">SemiClosedHandle</span></a></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Integer
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_semiclosedHandle"><span class="hs-identifier hs-var">ioe_semiclosedHandle</span></a></span><span>
</span><span id="line-122"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushWriteBuffer"><span class="hs-identifier hs-var">flushWriteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679556252"><span class="hs-identifier hs-var">handle_</span></a></span><span>
</span><span id="line-123"></span><span>              </span><span id="local-6989586621679556224"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556224"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">dev -&gt; IO Integer
forall a. IODevice a =&gt; a -&gt; IO Integer
</span><a href="GHC.IO.Device.html#getSize"><span class="hs-identifier hs-var">IODevice.getSize</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679556231"><span class="hs-identifier hs-var">dev</span></a></span><span>
</span><span id="line-124"></span><span>              </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#debugIO"><span class="hs-identifier hs-var">debugIO</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO ()) -&gt; FilePath -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hFileSize: &quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556224"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot; &quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556254"><span class="hs-identifier hs-var">handle</span></a></span><span>
</span><span id="line-125"></span><span>              </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556224"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span> </span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span>
</span><span id="line-126"></span><span>                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; IO Integer
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556224"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-127"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO Integer
forall a. IOException -&gt; IO a
</span><a href="GHC.IO.Exception.html#ioException"><span class="hs-identifier hs-var">ioException</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
-&gt; IOErrorType
-&gt; FilePath
-&gt; FilePath
-&gt; Maybe CInt
-&gt; Maybe FilePath
-&gt; IOException
</span><a href="GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-var">IOError</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="GHC.IO.Exception.html#InappropriateType"><span class="hs-identifier hs-var">InappropriateType</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hFileSize&quot;</span></span><span>
</span><span id="line-128"></span><span>                                  </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;not a regular file&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe CInt
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe FilePath
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="hs-comment">-- | 'hSetFileSize' @hdl@ @size@ truncates the physical file with handle @hdl@ to @size@ bytes.</span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="annot"><a href="GHC.IO.Handle.html#hSetFileSize"><span class="hs-identifier hs-type">hSetFileSize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-135"></span><span id="hSetFileSize"><span class="annot"><span class="annottext">hSetFileSize :: Handle -&gt; Integer -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hSetFileSize"><span class="hs-identifier hs-var hs-var">hSetFileSize</span></a></span></span><span> </span><span id="local-6989586621679556216"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556216"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span id="local-6989586621679556215"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556215"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-136"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO ()) -&gt; IO ()
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSetFileSize&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556216"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO ()) -&gt; IO ()) -&gt; (Handle__ -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679556214"><span class="annot"><span class="annottext">handle_ :: Handle__
</span><a href="#local-6989586621679556214"><span class="hs-identifier hs-var">handle_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">haDevice :: ()
</span><a href="GHC.IO.Handle.Types.html#haDevice"><span class="hs-identifier hs-var">haDevice</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679556205"><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679556205"><span class="hs-identifier hs-var">dev</span></a></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-137"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679556214"><span class="hs-identifier hs-var">handle_</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-138"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO ()
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_closedHandle"><span class="hs-identifier hs-var">ioe_closedHandle</span></a></span><span>
</span><span id="line-139"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#SemiClosedHandle"><span class="hs-identifier hs-var">SemiClosedHandle</span></a></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO ()
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_semiclosedHandle"><span class="hs-identifier hs-var">ioe_semiclosedHandle</span></a></span><span>
</span><span id="line-140"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushWriteBuffer"><span class="hs-identifier hs-var">flushWriteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679556214"><span class="hs-identifier hs-var">handle_</span></a></span><span>
</span><span id="line-141"></span><span>              </span><span class="annot"><span class="annottext">dev -&gt; Integer -&gt; IO ()
forall a. IODevice a =&gt; a -&gt; Integer -&gt; IO ()
</span><a href="GHC.IO.Device.html#setSize"><span class="hs-identifier hs-var">IODevice.setSize</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679556205"><span class="hs-identifier hs-var">dev</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556215"><span class="hs-identifier hs-var">size</span></a></span><span>
</span><span id="line-142"></span><span>              </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-143"></span><span>
</span><span id="line-144"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-145"></span><span class="hs-comment">-- Detecting the End of Input</span><span>
</span><span id="line-146"></span><span>
</span><span id="line-147"></span><span class="hs-comment">-- | For a readable handle @hdl@, 'hIsEOF' @hdl@ returns</span><span>
</span><span id="line-148"></span><span class="hs-comment">-- 'True' if no further input can be taken from @hdl@ or for a</span><span>
</span><span id="line-149"></span><span class="hs-comment">-- physical file, if the current I\/O position is equal to the length of</span><span>
</span><span id="line-150"></span><span class="hs-comment">-- the file.  Otherwise, it returns 'False'.</span><span>
</span><span id="line-151"></span><span class="hs-comment">--</span><span>
</span><span id="line-152"></span><span class="hs-comment">-- NOTE: 'hIsEOF' may block, because it has to attempt to read from</span><span>
</span><span id="line-153"></span><span class="hs-comment">-- the stream to determine whether there is any more data to be read.</span><span>
</span><span id="line-154"></span><span>
</span><span id="line-155"></span><span class="annot"><a href="GHC.IO.Handle.html#hIsEOF"><span class="hs-identifier hs-type">hIsEOF</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-156"></span><span id="hIsEOF"><span class="annot"><span class="annottext">hIsEOF :: Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hIsEOF"><span class="hs-identifier hs-var hs-var">hIsEOF</span></a></span></span><span> </span><span id="local-6989586621679556203"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556203"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#wantReadableHandle_"><span class="hs-identifier hs-var">wantReadableHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hIsEOF&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556203"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Bool) -&gt; IO Bool)
-&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679556172"><span id="local-6989586621679556173"><span id="local-6989586621679556174"><span id="local-6989586621679556175"><span id="local-6989586621679556176"><span id="local-6989586621679556177"><span id="local-6989586621679556178"><span id="local-6989586621679556179"><span id="local-6989586621679556180"><span id="local-6989586621679556181"><span id="local-6989586621679556182"><span id="local-6989586621679556183"><span id="local-6989586621679556184"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="GHC.IO.Handle.Types.html#haOutputNL"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span>  </span><span id="local-6989586621679556160"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679556160"><span class="hs-identifier hs-var">cbuf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem) -&gt; IO (Buffer CharBufElem)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem)
</span><a href="#local-6989586621679556179"><span class="hs-identifier hs-var">haCharBuffer</span></a></span><span>
</span><span id="line-159"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#not"><span class="hs-identifier hs-var">not</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; Bool
forall e. Buffer e -&gt; Bool
</span><a href="GHC.IO.Buffer.html#isEmptyBuffer"><span class="hs-identifier hs-var">isEmptyBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679556160"><span class="hs-identifier hs-var">cbuf</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-160"></span><span>
</span><span id="line-161"></span><span>  </span><span id="local-6989586621679556156"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679556156"><span class="hs-identifier hs-var">bbuf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; IO (Buffer Word8)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679556182"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span>
</span><span id="line-162"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#not"><span class="hs-identifier hs-var">not</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Word8 -&gt; Bool
forall e. Buffer e -&gt; Bool
</span><a href="GHC.IO.Buffer.html#isEmptyBuffer"><span class="hs-identifier hs-var">isEmptyBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679556156"><span class="hs-identifier hs-var">bbuf</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-163"></span><span>
</span><span id="line-164"></span><span>  </span><span class="hs-comment">-- NB. do no decoding, just fill the byte buffer; see #3808</span><span>
</span><span id="line-165"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621679556155"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679556155"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679556154"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679556154"><span class="hs-identifier hs-var">bbuf'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">dev -&gt; Buffer Word8 -&gt; IO (Int, Buffer Word8)
forall dev.
BufferedIO dev =&gt;
dev -&gt; Buffer Word8 -&gt; IO (Int, Buffer Word8)
</span><a href="GHC.IO.BufferedIO.html#fillReadBuffer"><span class="hs-identifier hs-var">Buffered.fillReadBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679556184"><span class="hs-identifier hs-var">haDevice</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679556156"><span class="hs-identifier hs-var">bbuf</span></a></span><span>
</span><span id="line-166"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679556155"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-167"></span><span>     </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-168"></span><span>     </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; Buffer Word8 -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679556182"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679556154"><span class="hs-identifier hs-var">bbuf'</span></a></span><span>
</span><span id="line-169"></span><span>             </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-170"></span><span>
</span><span id="line-171"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-172"></span><span class="hs-comment">-- isEOF</span><span>
</span><span id="line-173"></span><span>
</span><span id="line-174"></span><span class="hs-comment">-- | The computation 'isEOF' is identical to 'hIsEOF',</span><span>
</span><span id="line-175"></span><span class="hs-comment">-- except that it works only on 'stdin'.</span><span>
</span><span id="line-176"></span><span>
</span><span id="line-177"></span><span class="annot"><a href="GHC.IO.Handle.html#isEOF"><span class="hs-identifier hs-type">isEOF</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-178"></span><span id="isEOF"><span class="annot"><span class="annottext">isEOF :: IO Bool
</span><a href="GHC.IO.Handle.html#isEOF"><span class="hs-identifier hs-var hs-var">isEOF</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hIsEOF"><span class="hs-identifier hs-var">hIsEOF</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="GHC.IO.StdHandles.html#stdin"><span class="hs-identifier hs-var">stdin</span></a></span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-181"></span><span class="hs-comment">-- Looking ahead</span><span>
</span><span id="line-182"></span><span>
</span><span id="line-183"></span><span class="hs-comment">-- | Computation 'hLookAhead' returns the next character from the handle</span><span>
</span><span id="line-184"></span><span class="hs-comment">-- without removing it from the input buffer, blocking until a character</span><span>
</span><span id="line-185"></span><span class="hs-comment">-- is available.</span><span>
</span><span id="line-186"></span><span class="hs-comment">--</span><span>
</span><span id="line-187"></span><span class="hs-comment">-- This operation may fail with:</span><span>
</span><span id="line-188"></span><span class="hs-comment">--</span><span>
</span><span id="line-189"></span><span class="hs-comment">--  * 'System.IO.Error.isEOFError' if the end of file has been reached.</span><span>
</span><span id="line-190"></span><span>
</span><span id="line-191"></span><span class="annot"><a href="GHC.IO.Handle.html#hLookAhead"><span class="hs-identifier hs-type">hLookAhead</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span>
</span><span id="line-192"></span><span id="hLookAhead"><span class="annot"><span class="annottext">hLookAhead :: Handle -&gt; IO CharBufElem
</span><a href="GHC.IO.Handle.html#hLookAhead"><span class="hs-identifier hs-var hs-var">hLookAhead</span></a></span></span><span> </span><span id="local-6989586621679556150"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556150"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-193"></span><span>  </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle -&gt; (Handle__ -&gt; IO CharBufElem) -&gt; IO CharBufElem
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#wantReadableHandle_"><span class="hs-identifier hs-var">wantReadableHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hLookAhead&quot;</span></span><span>  </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556150"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO CharBufElem
</span><a href="GHC.IO.Handle.Internals.html#hLookAhead_"><span class="hs-identifier hs-var">hLookAhead_</span></a></span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-196"></span><span class="hs-comment">-- Buffering Operations</span><span>
</span><span id="line-197"></span><span>
</span><span id="line-198"></span><span class="hs-comment">-- Three kinds of buffering are supported: line-buffering,</span><span>
</span><span id="line-199"></span><span class="hs-comment">-- block-buffering or no-buffering.  See GHC.IO.Handle for definition and</span><span>
</span><span id="line-200"></span><span class="hs-comment">-- further explanation of what the type represent.</span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span class="hs-comment">-- | Computation 'hSetBuffering' @hdl mode@ sets the mode of buffering for</span><span>
</span><span id="line-203"></span><span class="hs-comment">-- handle @hdl@ on subsequent reads and writes.</span><span>
</span><span id="line-204"></span><span class="hs-comment">--</span><span>
</span><span id="line-205"></span><span class="hs-comment">-- If the buffer mode is changed from 'BlockBuffering' or</span><span>
</span><span id="line-206"></span><span class="hs-comment">-- 'LineBuffering' to 'NoBuffering', then</span><span>
</span><span id="line-207"></span><span class="hs-comment">--</span><span>
</span><span id="line-208"></span><span class="hs-comment">--  * if @hdl@ is writable, the buffer is flushed as for 'hFlush';</span><span>
</span><span id="line-209"></span><span class="hs-comment">--</span><span>
</span><span id="line-210"></span><span class="hs-comment">--  * if @hdl@ is not writable, the contents of the buffer is discarded.</span><span>
</span><span id="line-211"></span><span class="hs-comment">--</span><span>
</span><span id="line-212"></span><span class="hs-comment">-- This operation may fail with:</span><span>
</span><span id="line-213"></span><span class="hs-comment">--</span><span>
</span><span id="line-214"></span><span class="hs-comment">--  * 'System.IO.Error.isPermissionError' if the handle has already been used</span><span>
</span><span id="line-215"></span><span class="hs-comment">--    for reading or writing and the implementation does not allow the</span><span>
</span><span id="line-216"></span><span class="hs-comment">--    buffering mode to be changed.</span><span>
</span><span id="line-217"></span><span>
</span><span id="line-218"></span><span class="annot"><a href="GHC.IO.Handle.html#hSetBuffering"><span class="hs-identifier hs-type">hSetBuffering</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferMode"><span class="hs-identifier hs-type">BufferMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-219"></span><span id="hSetBuffering"><span class="annot"><span class="annottext">hSetBuffering :: Handle -&gt; BufferMode -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hSetBuffering"><span class="hs-identifier hs-var hs-var">hSetBuffering</span></a></span></span><span> </span><span id="local-6989586621679556148"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556148"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span id="local-6989586621679556147"><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679556147"><span class="hs-identifier hs-var">mode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-220"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#withAllHandles__"><span class="hs-identifier hs-var">withAllHandles__</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSetBuffering&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556148"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle__) -&gt; IO ())
-&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679556145"><span class="annot"><span class="annottext">handle_ :: Handle__
</span><a href="#local-6989586621679556145"><span class="hs-identifier hs-var">handle_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679556107"><span id="local-6989586621679556108"><span id="local-6989586621679556109"><span id="local-6989586621679556110"><span id="local-6989586621679556111"><span id="local-6989586621679556112"><span id="local-6989586621679556113"><span id="local-6989586621679556114"><span id="local-6989586621679556115"><span id="local-6989586621679556116"><span id="local-6989586621679556117"><span id="local-6989586621679556118"><span id="local-6989586621679556119"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679556107"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-221"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679556118"><span class="hs-identifier hs-var">haType</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-222"></span><span>    </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Handle__
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_closedHandle"><span class="hs-identifier hs-var">ioe_closedHandle</span></a></span><span>
</span><span id="line-223"></span><span>    </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-224"></span><span>         </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679556147"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="annot"><span class="annottext">BufferMode -&gt; BufferMode -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679556116"><span class="hs-identifier hs-var">haBufferMode</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO Handle__
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679556145"><span class="hs-identifier hs-var">handle_</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-225"></span><span>
</span><span id="line-226"></span><span>         </span><span class="hs-comment">-- See [note Buffer Sizing] in GHC.IO.Handle.Types</span><span>
</span><span id="line-227"></span><span>
</span><span id="line-228"></span><span>          </span><span class="hs-comment">-- check for errors:</span><span>
</span><span id="line-229"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679556147"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-230"></span><span>              </span><span class="annot"><a href="GHC.IO.Handle.Types.html#BlockBuffering"><span class="hs-identifier hs-type">BlockBuffering</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679556105"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679556105"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679556105"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO ()
forall a. Int -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_bufsiz"><span class="hs-identifier hs-var">ioe_bufsiz</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679556105"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-231"></span><span>              </span><span class="annot"><span class="annottext">BufferMode
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-232"></span><span>
</span><span id="line-233"></span><span>          </span><span class="hs-comment">-- for input terminals we need to put the terminal into</span><span>
</span><span id="line-234"></span><span>          </span><span class="hs-comment">-- cooked or raw mode depending on the type of buffering.</span><span>
</span><span id="line-235"></span><span>          </span><span id="local-6989586621679556102"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679556102"><span class="hs-identifier hs-var">is_tty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">dev -&gt; IO Bool
forall a. IODevice a =&gt; a -&gt; IO Bool
</span><a href="GHC.IO.Device.html#isTerminal"><span class="hs-identifier hs-var">IODevice.isTerminal</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679556119"><span class="hs-identifier hs-var">haDevice</span></a></span><span>
</span><span id="line-236"></span><span>          </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679556102"><span class="hs-identifier hs-var">is_tty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType -&gt; Bool
</span><a href="GHC.IO.Handle.Types.html#isReadableHandleType"><span class="hs-identifier hs-var">isReadableHandleType</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679556118"><span class="hs-identifier hs-var">haType</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-237"></span><span>                </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679556147"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="hs-keyword">of</span><span class="hs-cpp">
#if !defined(mingw32_HOST_OS)
</span><span>        </span><span class="hs-comment">-- 'raw' mode under win32 is a bit too specialised (and troublesome</span><span>
</span><span id="line-240"></span><span>        </span><span class="hs-comment">-- for most common uses), so simply disable its use here when not using</span><span>
</span><span id="line-241"></span><span>        </span><span class="hs-comment">-- WinIO.</span><span>
</span><span id="line-242"></span><span>                  </span><span class="hs-identifier">NoBuffering</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IODevice.setRaw</span><span> </span><span class="hs-identifier">haDevice</span><span> </span><span class="hs-identifier">True</span><span class="hs-cpp">
#else
</span><span>                  </span><span class="annot"><span class="annottext">BufferMode
</span><a href="GHC.IO.Handle.Types.html#NoBuffering"><span class="hs-identifier hs-var">NoBuffering</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-var">&lt;!&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">dev -&gt; Bool -&gt; IO ()
forall a. IODevice a =&gt; a -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.Device.html#setRaw"><span class="hs-identifier hs-var">IODevice.setRaw</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679556119"><span class="hs-identifier hs-var">haDevice</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-cpp">
#endif
</span><span>                  </span><span class="annot"><span class="annottext">BufferMode
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">dev -&gt; Bool -&gt; IO ()
forall a. IODevice a =&gt; a -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.Device.html#setRaw"><span class="hs-identifier hs-var">IODevice.setRaw</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679556119"><span class="hs-identifier hs-var">haDevice</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-247"></span><span>
</span><span id="line-248"></span><span>          </span><span class="hs-comment">-- throw away spare buffers, they might be the wrong size</span><span>
</span><span id="line-249"></span><span>          </span><span class="annot"><span class="annottext">IORef (BufferList CharBufElem) -&gt; BufferList CharBufElem -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (BufferList CharBufElem)
</span><a href="#local-6989586621679556113"><span class="hs-identifier hs-var">haBuffers</span></a></span><span> </span><span class="annot"><span class="annottext">BufferList CharBufElem
forall e. BufferList e
</span><a href="GHC.IO.Handle.Types.html#BufferListNil"><span class="hs-identifier hs-var">BufferListNil</span></a></span><span>
</span><span id="line-250"></span><span>
</span><span id="line-251"></span><span>          </span><span class="annot"><span class="annottext">Handle__ -&gt; IO Handle__
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ :: forall dev enc_state dec_state.
(RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) =&gt;
dev
-&gt; HandleType
-&gt; IORef (Buffer Word8)
-&gt; BufferMode
-&gt; IORef (dec_state, Buffer Word8)
-&gt; IORef (Buffer CharBufElem)
-&gt; IORef (BufferList CharBufElem)
-&gt; Maybe (TextEncoder enc_state)
-&gt; Maybe (TextDecoder dec_state)
-&gt; Maybe TextEncoding
-&gt; Newline
-&gt; Newline
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
</span><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">haBufferMode :: BufferMode
</span><a href="GHC.IO.Handle.Types.html#haBufferMode"><span class="hs-identifier hs-var">haBufferMode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679556147"><span class="hs-identifier hs-var">mode</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Newline
haOtherSide :: Maybe (MVar Handle__)
haLastDecode :: IORef (dec_state, Buffer Word8)
haInputNL :: Newline
haEncoder :: Maybe (TextEncoder enc_state)
haDecoder :: Maybe (TextDecoder dec_state)
haCodec :: Maybe TextEncoding
haCharBuffer :: IORef (Buffer CharBufElem)
haByteBuffer :: IORef (Buffer Word8)
haBuffers :: IORef (BufferList CharBufElem)
haType :: HandleType
haDevice :: dev
</span><a href="#local-6989586621679556107"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-252"></span><span>
</span><span id="line-253"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-254"></span><span class="hs-comment">-- hSetEncoding</span><span>
</span><span id="line-255"></span><span>
</span><span id="line-256"></span><span class="hs-comment">-- | The action 'hSetEncoding' @hdl@ @encoding@ changes the text encoding</span><span>
</span><span id="line-257"></span><span class="hs-comment">-- for the handle @hdl@ to @encoding@.  The default encoding when a 'Handle' is</span><span>
</span><span id="line-258"></span><span class="hs-comment">-- created is 'System.IO.localeEncoding', namely the default encoding for the</span><span>
</span><span id="line-259"></span><span class="hs-comment">-- current locale.</span><span>
</span><span id="line-260"></span><span class="hs-comment">--</span><span>
</span><span id="line-261"></span><span class="hs-comment">-- To create a 'Handle' with no encoding at all, use 'openBinaryFile'.  To</span><span>
</span><span id="line-262"></span><span class="hs-comment">-- stop further encoding or decoding on an existing 'Handle', use</span><span>
</span><span id="line-263"></span><span class="hs-comment">-- 'hSetBinaryMode'.</span><span>
</span><span id="line-264"></span><span class="hs-comment">--</span><span>
</span><span id="line-265"></span><span class="hs-comment">-- 'hSetEncoding' may need to flush buffered data in order to change</span><span>
</span><span id="line-266"></span><span class="hs-comment">-- the encoding.</span><span>
</span><span id="line-267"></span><span class="hs-comment">--</span><span>
</span><span id="line-268"></span><span class="annot"><a href="GHC.IO.Handle.html#hSetEncoding"><span class="hs-identifier hs-type">hSetEncoding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-269"></span><span id="hSetEncoding"><span class="annot"><span class="annottext">hSetEncoding :: Handle -&gt; TextEncoding -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hSetEncoding"><span class="hs-identifier hs-var hs-var">hSetEncoding</span></a></span></span><span> </span><span id="local-6989586621679556093"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556093"><span class="hs-identifier hs-var">hdl</span></a></span></span><span> </span><span id="local-6989586621679556092"><span class="annot"><span class="annottext">TextEncoding
</span><a href="#local-6989586621679556092"><span class="hs-identifier hs-var">encoding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-270"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#withAllHandles__"><span class="hs-identifier hs-var">withAllHandles__</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSetEncoding&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556093"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle__) -&gt; IO ())
-&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679556091"><span class="annot"><span class="annottext">h_ :: Handle__
</span><a href="#local-6989586621679556091"><span class="hs-identifier hs-var">h_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679556072"><span id="local-6989586621679556073"><span id="local-6989586621679556074"><span id="local-6989586621679556075"><span id="local-6989586621679556076"><span id="local-6989586621679556077"><span id="local-6989586621679556078"><span id="local-6989586621679556079"><span id="local-6989586621679556080"><span id="local-6989586621679556081"><span id="local-6989586621679556082"><span id="local-6989586621679556083"><span id="local-6989586621679556084"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679556072"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-271"></span><span>    </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushCharBuffer"><span class="hs-identifier hs-var">flushCharBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679556091"><span class="hs-identifier hs-var">h_</span></a></span><span>
</span><span id="line-272"></span><span>    </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#closeTextCodecs"><span class="hs-identifier hs-var">closeTextCodecs</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679556091"><span class="hs-identifier hs-var">h_</span></a></span><span>
</span><span id="line-273"></span><span>    </span><span class="annot"><span class="annottext">Maybe TextEncoding
-&gt; HandleType
-&gt; (forall es ds.
    Maybe (TextEncoder es) -&gt; Maybe (TextDecoder ds) -&gt; IO Handle__)
-&gt; IO Handle__
forall a.
Maybe TextEncoding
-&gt; HandleType
-&gt; (forall es ds.
    Maybe (TextEncoder es) -&gt; Maybe (TextDecoder ds) -&gt; IO a)
-&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#openTextEncoding"><span class="hs-identifier hs-var">openTextEncoding</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TextEncoding -&gt; Maybe TextEncoding
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="#local-6989586621679556092"><span class="hs-identifier hs-var">encoding</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679556083"><span class="hs-identifier hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">((forall es ds.
  Maybe (TextEncoder es) -&gt; Maybe (TextDecoder ds) -&gt; IO Handle__)
 -&gt; IO Handle__)
-&gt; (forall es ds.
    Maybe (TextEncoder es) -&gt; Maybe (TextDecoder ds) -&gt; IO Handle__)
-&gt; IO Handle__
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679556061"><span class="annot"><span class="annottext">Maybe (TextEncoder es)
</span><a href="#local-6989586621679556061"><span class="hs-identifier hs-var">mb_encoder</span></a></span></span><span> </span><span id="local-6989586621679556060"><span class="annot"><span class="annottext">Maybe (TextDecoder ds)
</span><a href="#local-6989586621679556060"><span class="hs-identifier hs-var">mb_decoder</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-274"></span><span>    </span><span id="local-6989586621679556059"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679556059"><span class="hs-identifier hs-var">bbuf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; IO (Buffer Word8)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679556082"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span>
</span><span id="line-275"></span><span>    </span><span id="local-6989586621679556058"><span class="annot"><span class="annottext">IORef (ds, Buffer Word8)
</span><a href="#local-6989586621679556058"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(ds, Buffer Word8) -&gt; IO (IORef (ds, Buffer Word8))
forall a. a -&gt; IO (IORef a)
</span><a href="GHC.IORef.html#newIORef"><span class="hs-identifier hs-var">newIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; (ds, Buffer Word8)
forall a. FilePath -&gt; a
</span><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier hs-var">errorWithoutStackTrace</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;last_decode&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-276"></span><span>    </span><span class="annot"><span class="annottext">Handle__ -&gt; IO Handle__
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__ :: forall dev enc_state dec_state.
(RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) =&gt;
dev
-&gt; HandleType
-&gt; IORef (Buffer Word8)
-&gt; BufferMode
-&gt; IORef (dec_state, Buffer Word8)
-&gt; IORef (Buffer CharBufElem)
-&gt; IORef (BufferList CharBufElem)
-&gt; Maybe (TextEncoder enc_state)
-&gt; Maybe (TextDecoder dec_state)
-&gt; Maybe TextEncoding
-&gt; Newline
-&gt; Newline
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
</span><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">haLastDecode :: IORef (ds, Buffer Word8)
</span><a href="GHC.IO.Handle.Types.html#haLastDecode"><span class="hs-identifier hs-var">haLastDecode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef (ds, Buffer Word8)
</span><a href="#local-6989586621679556058"><span class="hs-identifier hs-var">ref</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-277"></span><span>                      </span><span class="annot"><span class="annottext">haDecoder :: Maybe (TextDecoder ds)
</span><a href="GHC.IO.Handle.Types.html#haDecoder"><span class="hs-identifier hs-var">haDecoder</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (TextDecoder ds)
</span><a href="#local-6989586621679556060"><span class="hs-identifier hs-var">mb_decoder</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-278"></span><span>                      </span><span class="annot"><span class="annottext">haEncoder :: Maybe (TextEncoder es)
</span><a href="GHC.IO.Handle.Types.html#haEncoder"><span class="hs-identifier hs-var">haEncoder</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (TextEncoder es)
</span><a href="#local-6989586621679556061"><span class="hs-identifier hs-var">mb_encoder</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-279"></span><span>                      </span><span class="annot"><span class="annottext">haCodec :: Maybe TextEncoding
</span><a href="GHC.IO.Handle.Types.html#haCodec"><span class="hs-identifier hs-var">haCodec</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; Maybe TextEncoding
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="#local-6989586621679556092"><span class="hs-identifier hs-var">encoding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Newline
haOtherSide :: Maybe (MVar Handle__)
haInputNL :: Newline
haCharBuffer :: IORef (Buffer CharBufElem)
haByteBuffer :: IORef (Buffer Word8)
haBuffers :: IORef (BufferList CharBufElem)
haBufferMode :: BufferMode
haType :: HandleType
haDevice :: dev
</span><a href="#local-6989586621679556072"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-280"></span><span>
</span><span id="line-281"></span><span class="hs-comment">-- | Return the current 'TextEncoding' for the specified 'Handle', or</span><span>
</span><span id="line-282"></span><span class="hs-comment">-- 'Nothing' if the 'Handle' is in binary mode.</span><span>
</span><span id="line-283"></span><span class="hs-comment">--</span><span>
</span><span id="line-284"></span><span class="hs-comment">-- Note that the 'TextEncoding' remembers nothing about the state of</span><span>
</span><span id="line-285"></span><span class="hs-comment">-- the encoder/decoder in use on this 'Handle'.  For example, if the</span><span>
</span><span id="line-286"></span><span class="hs-comment">-- encoding in use is UTF-16, then using 'hGetEncoding' and</span><span>
</span><span id="line-287"></span><span class="hs-comment">-- 'hSetEncoding' to save and restore the encoding may result in an</span><span>
</span><span id="line-288"></span><span class="hs-comment">-- extra byte-order-mark being written to the file.</span><span>
</span><span id="line-289"></span><span class="hs-comment">--</span><span>
</span><span id="line-290"></span><span class="annot"><a href="GHC.IO.Handle.html#hGetEncoding"><span class="hs-identifier hs-type">hGetEncoding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-291"></span><span id="hGetEncoding"><span class="annot"><span class="annottext">hGetEncoding :: Handle -&gt; IO (Maybe TextEncoding)
</span><a href="GHC.IO.Handle.html#hGetEncoding"><span class="hs-identifier hs-var hs-var">hGetEncoding</span></a></span></span><span> </span><span id="local-6989586621679556055"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556055"><span class="hs-identifier hs-var">hdl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-292"></span><span>  </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; (Handle__ -&gt; IO (Maybe TextEncoding))
-&gt; IO (Maybe TextEncoding)
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetEncoding&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556055"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO (Maybe TextEncoding)) -&gt; IO (Maybe TextEncoding))
-&gt; (Handle__ -&gt; IO (Maybe TextEncoding)) -&gt; IO (Maybe TextEncoding)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679556054"><span class="annot"><span class="annottext">h_ :: Handle__
</span><a href="#local-6989586621679556054"><span class="hs-identifier hs-var">h_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679556036"><span id="local-6989586621679556037"><span id="local-6989586621679556038"><span id="local-6989586621679556039"><span id="local-6989586621679556040"><span id="local-6989586621679556041"><span id="local-6989586621679556042"><span id="local-6989586621679556043"><span id="local-6989586621679556044"><span id="local-6989586621679556045"><span id="local-6989586621679556046"><span id="local-6989586621679556047"><span id="local-6989586621679556048"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679556036"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe TextEncoding -&gt; IO (Maybe TextEncoding)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TextEncoding
</span><a href="#local-6989586621679556039"><span class="hs-identifier hs-var">haCodec</span></a></span><span>
</span><span id="line-293"></span><span>
</span><span id="line-294"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-295"></span><span class="hs-comment">-- hFlush</span><span>
</span><span id="line-296"></span><span>
</span><span id="line-297"></span><span class="hs-comment">-- | The action 'hFlush' @hdl@ causes any items buffered for output</span><span>
</span><span id="line-298"></span><span class="hs-comment">-- in handle @hdl@ to be sent immediately to the operating system.</span><span>
</span><span id="line-299"></span><span class="hs-comment">--</span><span>
</span><span id="line-300"></span><span class="hs-comment">-- This operation may fail with:</span><span>
</span><span id="line-301"></span><span class="hs-comment">--</span><span>
</span><span id="line-302"></span><span class="hs-comment">--  * 'System.IO.Error.isFullError' if the device is full;</span><span>
</span><span id="line-303"></span><span class="hs-comment">--</span><span>
</span><span id="line-304"></span><span class="hs-comment">--  * 'System.IO.Error.isPermissionError' if a system resource limit would be</span><span>
</span><span id="line-305"></span><span class="hs-comment">--    exceeded. It is unspecified whether the characters in the buffer are</span><span>
</span><span id="line-306"></span><span class="hs-comment">--    discarded or retained under these circumstances.</span><span>
</span><span id="line-307"></span><span>
</span><span id="line-308"></span><span class="annot"><a href="GHC.IO.Handle.html#hFlush"><span class="hs-identifier hs-type">hFlush</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-309"></span><span id="hFlush"><span class="annot"><span class="annottext">hFlush :: Handle -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hFlush"><span class="hs-identifier hs-var hs-var">hFlush</span></a></span></span><span> </span><span id="local-6989586621679556035"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556035"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO ()) -&gt; IO ()
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#wantWritableHandle"><span class="hs-identifier hs-var">wantWritableHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hFlush&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556035"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushWriteBuffer"><span class="hs-identifier hs-var">flushWriteBuffer</span></a></span><span>
</span><span id="line-310"></span><span>
</span><span id="line-311"></span><span class="hs-comment">-- | The action 'hFlushAll' @hdl@ flushes all buffered data in @hdl@,</span><span>
</span><span id="line-312"></span><span class="hs-comment">-- including any buffered read data.  Buffered read data is flushed</span><span>
</span><span id="line-313"></span><span class="hs-comment">-- by seeking the file position back to the point before the bufferred</span><span>
</span><span id="line-314"></span><span class="hs-comment">-- data was read, and hence only works if @hdl@ is seekable (see</span><span>
</span><span id="line-315"></span><span class="hs-comment">-- 'hIsSeekable').</span><span>
</span><span id="line-316"></span><span class="hs-comment">--</span><span>
</span><span id="line-317"></span><span class="hs-comment">-- This operation may fail with:</span><span>
</span><span id="line-318"></span><span class="hs-comment">--</span><span>
</span><span id="line-319"></span><span class="hs-comment">--  * 'System.IO.Error.isFullError' if the device is full;</span><span>
</span><span id="line-320"></span><span class="hs-comment">--</span><span>
</span><span id="line-321"></span><span class="hs-comment">--  * 'System.IO.Error.isPermissionError' if a system resource limit would be</span><span>
</span><span id="line-322"></span><span class="hs-comment">--    exceeded. It is unspecified whether the characters in the buffer are</span><span>
</span><span id="line-323"></span><span class="hs-comment">--    discarded or retained under these circumstances;</span><span>
</span><span id="line-324"></span><span class="hs-comment">--</span><span>
</span><span id="line-325"></span><span class="hs-comment">--  * 'System.IO.Error.isIllegalOperation' if @hdl@ has buffered read data, and</span><span>
</span><span id="line-326"></span><span class="hs-comment">--    is not seekable.</span><span>
</span><span id="line-327"></span><span>
</span><span id="line-328"></span><span class="annot"><a href="GHC.IO.Handle.html#hFlushAll"><span class="hs-identifier hs-type">hFlushAll</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span id="hFlushAll"><span class="annot"><span class="annottext">hFlushAll :: Handle -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hFlushAll"><span class="hs-identifier hs-var hs-var">hFlushAll</span></a></span></span><span> </span><span id="local-6989586621679556033"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556033"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO ()) -&gt; IO ()
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hFlushAll&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556033"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushBuffer"><span class="hs-identifier hs-var">flushBuffer</span></a></span><span>
</span><span id="line-330"></span><span>
</span><span id="line-331"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-332"></span><span class="hs-comment">-- Repositioning Handles</span><span>
</span><span id="line-333"></span><span>
</span><span id="line-334"></span><span class="hs-keyword">data</span><span> </span><span id="HandlePosn"><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-var">HandlePosn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="HandlePosn"><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-var">HandlePosn</span></a></span></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosition"><span class="hs-identifier hs-type">HandlePosition</span></a></span><span>
</span><span id="line-335"></span><span>
</span><span id="line-336"></span><span class="hs-comment">-- | @since 4.1.0.0</span><span>
</span><span id="line-337"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679556028"><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-type">Eq</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-type">HandlePosn</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-338"></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-type">HandlePosn</span></a></span><span> </span><span id="local-6989586621679556023"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556023"><span class="hs-identifier hs-var">h1</span></a></span></span><span> </span><span id="local-6989586621679556022"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556022"><span class="hs-identifier hs-var">p1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679556021"><span class="annot"><span class="annottext">== :: HandlePosn -&gt; HandlePosn -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">==</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-type">HandlePosn</span></a></span><span> </span><span id="local-6989586621679556020"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556020"><span class="hs-identifier hs-var">h2</span></a></span></span><span> </span><span id="local-6989586621679556019"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556019"><span class="hs-identifier hs-var">p2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556022"><span class="hs-identifier hs-var">p1</span></a></span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556019"><span class="hs-identifier hs-var">p2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556023"><span class="hs-identifier hs-var">h1</span></a></span><span class="annot"><span class="annottext">Handle -&gt; Handle -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556020"><span class="hs-identifier hs-var">h2</span></a></span><span>
</span><span id="line-339"></span><span>
</span><span id="line-340"></span><span class="hs-comment">-- | @since 4.1.0.0</span><span>
</span><span id="line-341"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679556014"><span id="local-6989586621679556016"><span class="annot"><a href="GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-type">HandlePosn</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-342"></span><span>   </span><span id="local-6989586621679556010"><span class="annot"><span class="annottext">showsPrec :: Int -&gt; HandlePosn -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showsPrec"><span class="hs-identifier hs-var hs-var hs-var hs-var">showsPrec</span></a></span></span><span> </span><span id="local-6989586621679556008"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679556008"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-type">HandlePosn</span></a></span><span> </span><span id="local-6989586621679556007"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556007"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679556006"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556006"><span class="hs-identifier hs-var">pos</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-343"></span><span>        </span><span class="annot"><span class="annottext">Int -&gt; Handle -&gt; FilePath -&gt; FilePath
forall a. Show a =&gt; Int -&gt; a -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showsPrec"><span class="hs-identifier hs-var">showsPrec</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679556008"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556007"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot; at position &quot;</span></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; FilePath -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#shows"><span class="hs-identifier hs-var">shows</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556006"><span class="hs-identifier hs-var">pos</span></a></span><span>
</span><span id="line-344"></span><span>
</span><span id="line-345"></span><span>  </span><span class="hs-comment">-- HandlePosition is the Haskell equivalent of POSIX' off_t.</span><span>
</span><span id="line-346"></span><span>  </span><span class="hs-comment">-- We represent it as an Integer on the Haskell side, but</span><span>
</span><span id="line-347"></span><span>  </span><span class="hs-comment">-- cheat slightly in that hGetPosn calls upon a C helper</span><span>
</span><span id="line-348"></span><span>  </span><span class="hs-comment">-- that reports the position back via (merely) an Int.</span><span>
</span><span id="line-349"></span><span class="hs-keyword">type</span><span> </span><span id="HandlePosition"><span class="annot"><a href="GHC.IO.Handle.html#HandlePosition"><span class="hs-identifier hs-var">HandlePosition</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span>
</span><span id="line-350"></span><span>
</span><span id="line-351"></span><span class="hs-comment">-- | Computation 'hGetPosn' @hdl@ returns the current I\/O position of</span><span>
</span><span id="line-352"></span><span class="hs-comment">-- @hdl@ as a value of the abstract type 'HandlePosn'.</span><span>
</span><span id="line-353"></span><span>
</span><span id="line-354"></span><span class="annot"><a href="GHC.IO.Handle.html#hGetPosn"><span class="hs-identifier hs-type">hGetPosn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-type">HandlePosn</span></a></span><span>
</span><span id="line-355"></span><span id="hGetPosn"><span class="annot"><span class="annottext">hGetPosn :: Handle -&gt; IO HandlePosn
</span><a href="GHC.IO.Handle.html#hGetPosn"><span class="hs-identifier hs-var hs-var">hGetPosn</span></a></span></span><span> </span><span id="local-6989586621679556002"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556002"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-356"></span><span>    </span><span id="local-6989586621679556001"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556001"><span class="hs-identifier hs-var">posn</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Integer
</span><a href="GHC.IO.Handle.html#hTell"><span class="hs-identifier hs-var">hTell</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556002"><span class="hs-identifier hs-var">handle</span></a></span><span>
</span><span id="line-357"></span><span>    </span><span class="annot"><span class="annottext">HandlePosn -&gt; IO HandlePosn
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; Integer -&gt; HandlePosn
</span><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-var">HandlePosn</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556002"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679556001"><span class="hs-identifier hs-var">posn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-358"></span><span>
</span><span id="line-359"></span><span class="hs-comment">-- | If a call to 'hGetPosn' @hdl@ returns a position @p@,</span><span>
</span><span id="line-360"></span><span class="hs-comment">-- then computation 'hSetPosn' @p@ sets the position of @hdl@</span><span>
</span><span id="line-361"></span><span class="hs-comment">-- to the position it held at the time of the call to 'hGetPosn'.</span><span>
</span><span id="line-362"></span><span class="hs-comment">--</span><span>
</span><span id="line-363"></span><span class="hs-comment">-- This operation may fail with:</span><span>
</span><span id="line-364"></span><span class="hs-comment">--</span><span>
</span><span id="line-365"></span><span class="hs-comment">--  * 'System.IO.Error.isPermissionError' if a system resource limit would be</span><span>
</span><span id="line-366"></span><span class="hs-comment">--    exceeded.</span><span>
</span><span id="line-367"></span><span>
</span><span id="line-368"></span><span class="annot"><a href="GHC.IO.Handle.html#hSetPosn"><span class="hs-identifier hs-type">hSetPosn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-type">HandlePosn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-369"></span><span id="hSetPosn"><span class="annot"><span class="annottext">hSetPosn :: HandlePosn -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hSetPosn"><span class="hs-identifier hs-var hs-var">hSetPosn</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.html#HandlePosn"><span class="hs-identifier hs-type">HandlePosn</span></a></span><span> </span><span id="local-6989586621679556000"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556000"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679555999"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555999"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; SeekMode -&gt; Integer -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hSeek"><span class="hs-identifier hs-var">hSeek</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679556000"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">SeekMode
</span><a href="GHC.IO.Device.html#AbsoluteSeek"><span class="hs-identifier hs-var">AbsoluteSeek</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555999"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-370"></span><span>
</span><span id="line-371"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-372"></span><span class="hs-comment">-- hSeek</span><span>
</span><span id="line-373"></span><span>
</span><span id="line-374"></span><span class="hs-comment">{- Note:
 - when seeking using `SeekFromEnd', positive offsets (&gt;=0) means
   seeking at or past EOF.

 - we possibly deviate from the report on the issue of seeking within
   the buffer and whether to flush it or not.  The report isn't exactly
   clear here.
-}</span><span>
</span><span id="line-382"></span><span>
</span><span id="line-383"></span><span class="hs-comment">-- | Computation 'hSeek' @hdl mode i@ sets the position of handle</span><span>
</span><span id="line-384"></span><span class="hs-comment">-- @hdl@ depending on @mode@.</span><span>
</span><span id="line-385"></span><span class="hs-comment">-- The offset @i@ is given in terms of 8-bit bytes.</span><span>
</span><span id="line-386"></span><span class="hs-comment">--</span><span>
</span><span id="line-387"></span><span class="hs-comment">-- If @hdl@ is block- or line-buffered, then seeking to a position which is not</span><span>
</span><span id="line-388"></span><span class="hs-comment">-- in the current buffer will first cause any items in the output buffer to be</span><span>
</span><span id="line-389"></span><span class="hs-comment">-- written to the device, and then cause the input buffer to be discarded.</span><span>
</span><span id="line-390"></span><span class="hs-comment">-- Some handles may not be seekable (see 'hIsSeekable'), or only support a</span><span>
</span><span id="line-391"></span><span class="hs-comment">-- subset of the possible positioning operations (for instance, it may only</span><span>
</span><span id="line-392"></span><span class="hs-comment">-- be possible to seek to the end of a tape, or to a positive offset from</span><span>
</span><span id="line-393"></span><span class="hs-comment">-- the beginning or current position).</span><span>
</span><span id="line-394"></span><span class="hs-comment">-- It is not possible to set a negative I\/O position, or for</span><span>
</span><span id="line-395"></span><span class="hs-comment">-- a physical file, an I\/O position beyond the current end-of-file.</span><span>
</span><span id="line-396"></span><span class="hs-comment">--</span><span>
</span><span id="line-397"></span><span class="hs-comment">-- This operation may fail with:</span><span>
</span><span id="line-398"></span><span class="hs-comment">--</span><span>
</span><span id="line-399"></span><span class="hs-comment">--  * 'System.IO.Error.isIllegalOperationError' if the Handle is not seekable,</span><span>
</span><span id="line-400"></span><span class="hs-comment">--    or does not support the requested seek mode.</span><span>
</span><span id="line-401"></span><span class="hs-comment">--</span><span>
</span><span id="line-402"></span><span class="hs-comment">--  * 'System.IO.Error.isPermissionError' if a system resource limit would be</span><span>
</span><span id="line-403"></span><span class="hs-comment">--    exceeded.</span><span>
</span><span id="line-404"></span><span>
</span><span id="line-405"></span><span class="annot"><a href="GHC.IO.Handle.html#hSeek"><span class="hs-identifier hs-type">hSeek</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Device.html#SeekMode"><span class="hs-identifier hs-type">SeekMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-406"></span><span id="hSeek"><span class="annot"><span class="annottext">hSeek :: Handle -&gt; SeekMode -&gt; Integer -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hSeek"><span class="hs-identifier hs-var hs-var">hSeek</span></a></span></span><span> </span><span id="local-6989586621679555997"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555997"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span id="local-6989586621679555996"><span class="annot"><span class="annottext">SeekMode
</span><a href="#local-6989586621679555996"><span class="hs-identifier hs-var">mode</span></a></span></span><span> </span><span id="local-6989586621679555995"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555995"><span class="hs-identifier hs-var">offset</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-407"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO ()) -&gt; IO ()
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#wantSeekableHandle"><span class="hs-identifier hs-var">wantSeekableHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSeek&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555997"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO ()) -&gt; IO ()) -&gt; (Handle__ -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555993"><span class="annot"><span class="annottext">handle_ :: Handle__
</span><a href="#local-6989586621679555993"><span class="hs-identifier hs-var">handle_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679555934"><span id="local-6989586621679555935"><span id="local-6989586621679555936"><span id="local-6989586621679555937"><span id="local-6989586621679555938"><span id="local-6989586621679555939"><span id="local-6989586621679555940"><span id="local-6989586621679555941"><span id="local-6989586621679555942"><span id="local-6989586621679555943"><span id="local-6989586621679555944"><span id="local-6989586621679555945"><span id="local-6989586621679555946"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679555934"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-408"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#debugIO"><span class="hs-identifier hs-var">debugIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSeek &quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(SeekMode, Integer) -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SeekMode
</span><a href="#local-6989586621679555996"><span class="hs-identifier hs-var">mode</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555995"><span class="hs-identifier hs-var">offset</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-409"></span><span>    </span><span id="local-6989586621679555933"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679555933"><span class="hs-identifier hs-var">cbuf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem) -&gt; IO (Buffer CharBufElem)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem)
</span><a href="#local-6989586621679555941"><span class="hs-identifier hs-var">haCharBuffer</span></a></span><span>
</span><span id="line-410"></span><span>    </span><span id="local-6989586621679555932"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555932"><span class="hs-identifier hs-var">bbuf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; IO (Buffer Word8)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679555944"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span>
</span><span id="line-411"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#debugIO"><span class="hs-identifier hs-var">debugIO</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO ()) -&gt; FilePath -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSeek - bbuf:&quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8 -&gt; FilePath
forall a. Buffer a -&gt; FilePath
</span><a href="GHC.IO.Buffer.html#summaryBuffer"><span class="hs-identifier hs-var">summaryBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555932"><span class="hs-identifier hs-var">bbuf</span></a></span><span>
</span><span id="line-412"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#debugIO"><span class="hs-identifier hs-var">debugIO</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO ()) -&gt; FilePath -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSeek - cbuf:&quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; FilePath
forall a. Buffer a -&gt; FilePath
</span><a href="GHC.IO.Buffer.html#summaryBuffer"><span class="hs-identifier hs-var">summaryBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679555933"><span class="hs-identifier hs-var">cbuf</span></a></span><span>
</span><span id="line-413"></span><span>
</span><span id="line-414"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; Bool
forall e. Buffer e -&gt; Bool
</span><a href="GHC.IO.Buffer.html#isWriteBuffer"><span class="hs-identifier hs-var">isWriteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679555933"><span class="hs-identifier hs-var">cbuf</span></a></span><span>
</span><span id="line-415"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushWriteBuffer"><span class="hs-identifier hs-var">flushWriteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555993"><span class="hs-identifier hs-var">handle_</span></a></span><span>
</span><span id="line-416"></span><span>                </span><span id="local-6989586621679555929"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555929"><span class="hs-identifier hs-var">new_offset</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">dev -&gt; SeekMode -&gt; Integer -&gt; IO Integer
forall a. IODevice a =&gt; a -&gt; SeekMode -&gt; Integer -&gt; IO Integer
</span><a href="GHC.IO.Device.html#seek"><span class="hs-identifier hs-var">IODevice.seek</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555946"><span class="hs-identifier hs-var">haDevice</span></a></span><span> </span><span class="annot"><span class="annottext">SeekMode
</span><a href="#local-6989586621679555996"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555995"><span class="hs-identifier hs-var">offset</span></a></span><span>
</span><span id="line-417"></span><span>                </span><span class="hs-comment">-- buffer has been updated, need to re-read it</span><span>
</span><span id="line-418"></span><span>                </span><span id="local-6989586621679555927"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555927"><span class="hs-identifier hs-var">bbuf1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; IO (Buffer Word8)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679555944"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span>
</span><span id="line-419"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679555924"><span class="annot"><span class="annottext">bbuf2 :: Buffer Word8
</span><a href="#local-6989586621679555924"><span class="hs-identifier hs-var hs-var">bbuf2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555927"><span class="hs-identifier hs-var">bbuf1</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufOffset :: Word64
</span><a href="GHC.IO.Buffer.html#bufOffset"><span class="hs-identifier hs-var">bufOffset</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555929"><span class="hs-identifier hs-var">new_offset</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-420"></span><span>                </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#debugIO"><span class="hs-identifier hs-var">debugIO</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO ()) -&gt; FilePath -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSeek - seek:: &quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555995"><span class="hs-identifier hs-var">offset</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-421"></span><span>                          </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot; - &quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555929"><span class="hs-identifier hs-var">new_offset</span></a></span><span>
</span><span id="line-422"></span><span>                </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#debugIO"><span class="hs-identifier hs-var">debugIO</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO ()) -&gt; FilePath -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSeek - wr flush bbuf1:&quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8 -&gt; FilePath
forall a. Buffer a -&gt; FilePath
</span><a href="GHC.IO.Buffer.html#summaryBuffer"><span class="hs-identifier hs-var">summaryBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555924"><span class="hs-identifier hs-var">bbuf2</span></a></span><span>
</span><span id="line-423"></span><span>                </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; Buffer Word8 -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679555944"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555924"><span class="hs-identifier hs-var">bbuf2</span></a></span><span>
</span><span id="line-424"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-425"></span><span>
</span><span id="line-426"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679555922"><span class="annot"><span class="annottext">r :: Int
</span><a href="#local-6989586621679555922"><span class="hs-identifier hs-var hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; Int
forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var hs-var">bufL</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679555933"><span class="hs-identifier hs-var">cbuf</span></a></span><span class="hs-special">;</span><span> </span><span id="local-6989586621679555920"><span class="annot"><span class="annottext">w :: Int
</span><a href="#local-6989586621679555920"><span class="hs-identifier hs-var hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; Int
forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufR"><span class="hs-identifier hs-var hs-var">bufR</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679555933"><span class="hs-identifier hs-var">cbuf</span></a></span><span>
</span><span id="line-427"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">SeekMode
</span><a href="#local-6989586621679555996"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="annot"><span class="annottext">SeekMode -&gt; SeekMode -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">SeekMode
</span><a href="GHC.IO.Device.html#RelativeSeek"><span class="hs-identifier hs-var">RelativeSeek</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (TextDecoder dec_state) -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="Data.Maybe.html#isNothing"><span class="hs-identifier hs-var">isNothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (TextDecoder dec_state)
</span><a href="#local-6989586621679555938"><span class="hs-identifier hs-var">haDecoder</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span>
</span><span id="line-428"></span><span>       </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555995"><span class="hs-identifier hs-var">offset</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555995"><span class="hs-identifier hs-var">offset</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Integer
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679555920"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679555922"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-429"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem) -&gt; Buffer CharBufElem -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem)
</span><a href="#local-6989586621679555941"><span class="hs-identifier hs-var">haCharBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679555933"><span class="hs-identifier hs-var">cbuf</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufL :: Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679555922"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555995"><span class="hs-identifier hs-var">offset</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-430"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-431"></span><span>
</span><span id="line-432"></span><span>    </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushCharReadBuffer"><span class="hs-identifier hs-var">flushCharReadBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555993"><span class="hs-identifier hs-var">handle_</span></a></span><span>
</span><span id="line-433"></span><span>    </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushByteReadBuffer"><span class="hs-identifier hs-var">flushByteReadBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555993"><span class="hs-identifier hs-var">handle_</span></a></span><span>
</span><span id="line-434"></span><span>    </span><span class="hs-comment">-- read the updated values</span><span>
</span><span id="line-435"></span><span>    </span><span id="local-6989586621679555912"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555912"><span class="hs-identifier hs-var">bbuf2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; IO (Buffer Word8)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679555944"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span>
</span><span id="line-436"></span><span>    </span><span id="local-6989586621679555911"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555911"><span class="hs-identifier hs-var">new_offset</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">dev -&gt; SeekMode -&gt; Integer -&gt; IO Integer
forall a. IODevice a =&gt; a -&gt; SeekMode -&gt; Integer -&gt; IO Integer
</span><a href="GHC.IO.Device.html#seek"><span class="hs-identifier hs-var">IODevice.seek</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555946"><span class="hs-identifier hs-var">haDevice</span></a></span><span> </span><span class="annot"><span class="annottext">SeekMode
</span><a href="#local-6989586621679555996"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555995"><span class="hs-identifier hs-var">offset</span></a></span><span>
</span><span id="line-437"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#debugIO"><span class="hs-identifier hs-var">debugIO</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; IO ()) -&gt; FilePath -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSeek after: &quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555911"><span class="hs-identifier hs-var">new_offset</span></a></span><span>
</span><span id="line-438"></span><span>    </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; Buffer Word8 -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679555944"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555912"><span class="hs-identifier hs-var">bbuf2</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufOffset :: Word64
</span><a href="GHC.IO.Buffer.html#bufOffset"><span class="hs-identifier hs-var">bufOffset</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555911"><span class="hs-identifier hs-var">new_offset</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-439"></span><span>
</span><span id="line-440"></span><span>
</span><span id="line-441"></span><span class="hs-comment">-- | Computation 'hTell' @hdl@ returns the current position of the</span><span>
</span><span id="line-442"></span><span class="hs-comment">-- handle @hdl@, as the number of bytes from the beginning of</span><span>
</span><span id="line-443"></span><span class="hs-comment">-- the file.  The value returned may be subsequently passed to</span><span>
</span><span id="line-444"></span><span class="hs-comment">-- 'hSeek' to reposition the handle to the current position.</span><span>
</span><span id="line-445"></span><span class="hs-comment">--</span><span>
</span><span id="line-446"></span><span class="hs-comment">-- This operation may fail with:</span><span>
</span><span id="line-447"></span><span class="hs-comment">--</span><span>
</span><span id="line-448"></span><span class="hs-comment">--  * 'System.IO.Error.isIllegalOperationError' if the Handle is not seekable.</span><span>
</span><span id="line-449"></span><span class="hs-comment">--</span><span>
</span><span id="line-450"></span><span class="annot"><a href="GHC.IO.Handle.html#hTell"><span class="hs-identifier hs-type">hTell</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span>
</span><span id="line-451"></span><span id="hTell"><span class="annot"><span class="annottext">hTell :: Handle -&gt; IO Integer
</span><a href="GHC.IO.Handle.html#hTell"><span class="hs-identifier hs-var hs-var">hTell</span></a></span></span><span> </span><span id="local-6989586621679555910"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555910"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-452"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Integer) -&gt; IO Integer
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#wantSeekableHandle"><span class="hs-identifier hs-var">wantSeekableHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetPosn&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555910"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Integer) -&gt; IO Integer)
-&gt; (Handle__ -&gt; IO Integer) -&gt; IO Integer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555909"><span class="annot"><span class="annottext">handle_ :: Handle__
</span><a href="#local-6989586621679555909"><span class="hs-identifier hs-var">handle_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679555871"><span id="local-6989586621679555872"><span id="local-6989586621679555873"><span id="local-6989586621679555874"><span id="local-6989586621679555875"><span id="local-6989586621679555876"><span id="local-6989586621679555877"><span id="local-6989586621679555878"><span id="local-6989586621679555879"><span id="local-6989586621679555880"><span id="local-6989586621679555881"><span id="local-6989586621679555882"><span id="local-6989586621679555883"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679555871"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-453"></span><span>
</span><span id="line-454"></span><span>      </span><span class="hs-comment">-- TODO: Guard these on Windows</span><span>
</span><span id="line-455"></span><span>      </span><span id="local-6989586621679555870"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555870"><span class="hs-identifier hs-var">posn</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">IoSubSystem
</span><a href="GHC.IO.SubSystem.html#ioSubSystem"><span class="hs-identifier hs-var">ioSubSystem</span></a></span><span> </span><span class="annot"><span class="annottext">IoSubSystem -&gt; IoSubSystem -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">IoSubSystem
</span><a href="GHC.RTS.Flags.html#IoNative"><span class="hs-identifier hs-var">IoNative</span></a></span><span>
</span><span id="line-456"></span><span>                         </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word64 -&gt; Integer
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Word64 -&gt; Integer)
-&gt; (Buffer Word8 -&gt; Word64) -&gt; Buffer Word8 -&gt; Integer
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8 -&gt; Word64
forall e. Buffer e -&gt; Word64
</span><a href="GHC.IO.Buffer.html#bufOffset"><span class="hs-identifier hs-var hs-var">bufOffset</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Buffer Word8 -&gt; Integer) -&gt; IO (Buffer Word8) -&gt; IO Integer
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="GHC.Base.html#fmap"><span class="hs-operator hs-var">`fmap`</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; IO (Buffer Word8)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679555881"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span>
</span><span id="line-457"></span><span>                         </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">dev -&gt; IO Integer
forall a. IODevice a =&gt; a -&gt; IO Integer
</span><a href="GHC.IO.Device.html#tell"><span class="hs-identifier hs-var">IODevice.tell</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555883"><span class="hs-identifier hs-var">haDevice</span></a></span><span>
</span><span id="line-458"></span><span>
</span><span id="line-459"></span><span>      </span><span class="hs-comment">-- we can't tell the real byte offset if there are buffered</span><span>
</span><span id="line-460"></span><span>      </span><span class="hs-comment">-- Chars, so must flush first:</span><span>
</span><span id="line-461"></span><span>      </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushCharBuffer"><span class="hs-identifier hs-var">flushCharBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555909"><span class="hs-identifier hs-var">handle_</span></a></span><span>
</span><span id="line-462"></span><span>
</span><span id="line-463"></span><span>      </span><span id="local-6989586621679555866"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555866"><span class="hs-identifier hs-var">bbuf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; IO (Buffer Word8)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679555881"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span>
</span><span id="line-464"></span><span>      </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#debugIO"><span class="hs-identifier hs-var">debugIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hTell bbuf (elems=&quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Word8 -&gt; Int
forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufferElems"><span class="hs-identifier hs-var">bufferElems</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555866"><span class="hs-identifier hs-var">bbuf</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;)&quot;</span></span><span>
</span><span id="line-465"></span><span>               </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8 -&gt; FilePath
forall a. Buffer a -&gt; FilePath
</span><a href="GHC.IO.Buffer.html#summaryBuffer"><span class="hs-identifier hs-var">summaryBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555866"><span class="hs-identifier hs-var">bbuf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-466"></span><span>
</span><span id="line-467"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679555858"><span class="annot"><span class="annottext">real_posn :: Integer
</span><a href="#local-6989586621679555858"><span class="hs-identifier hs-var hs-var">real_posn</span></a></span></span><span>
</span><span id="line-468"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Buffer Word8 -&gt; Bool
forall e. Buffer e -&gt; Bool
</span><a href="GHC.IO.Buffer.html#isWriteBuffer"><span class="hs-identifier hs-var">isWriteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555866"><span class="hs-identifier hs-var">bbuf</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555870"><span class="hs-identifier hs-var">posn</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Integer
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Word8 -&gt; Int
forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufferElems"><span class="hs-identifier hs-var">bufferElems</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555866"><span class="hs-identifier hs-var">bbuf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-469"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555870"><span class="hs-identifier hs-var">posn</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Integer
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Word8 -&gt; Int
forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufferElems"><span class="hs-identifier hs-var">bufferElems</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555866"><span class="hs-identifier hs-var">bbuf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-470"></span><span>
</span><span id="line-471"></span><span>      </span><span id="local-6989586621679555857"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679555857"><span class="hs-identifier hs-var">cbuf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem) -&gt; IO (Buffer CharBufElem)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem)
</span><a href="#local-6989586621679555878"><span class="hs-identifier hs-var">haCharBuffer</span></a></span><span>
</span><span id="line-472"></span><span>      </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#debugIO"><span class="hs-identifier hs-var">debugIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;\nhGetPosn: (posn, real_posn) = &quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(Integer, Integer) -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath
</span><a href="GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555870"><span class="hs-identifier hs-var">posn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555858"><span class="hs-identifier hs-var">real_posn</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-473"></span><span>      </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#debugIO"><span class="hs-identifier hs-var">debugIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;   cbuf: &quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; FilePath
forall a. Buffer a -&gt; FilePath
</span><a href="GHC.IO.Buffer.html#summaryBuffer"><span class="hs-identifier hs-var">summaryBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679555857"><span class="hs-identifier hs-var">cbuf</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-474"></span><span>               </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;   bbuf: &quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8 -&gt; FilePath
forall a. Buffer a -&gt; FilePath
</span><a href="GHC.IO.Buffer.html#summaryBuffer"><span class="hs-identifier hs-var">summaryBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555866"><span class="hs-identifier hs-var">bbuf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-475"></span><span>
</span><span id="line-476"></span><span>      </span><span class="annot"><span class="annottext">Integer -&gt; IO Integer
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679555858"><span class="hs-identifier hs-var">real_posn</span></a></span><span>
</span><span id="line-477"></span><span>
</span><span id="line-478"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-479"></span><span class="hs-comment">-- Handle Properties</span><span>
</span><span id="line-480"></span><span>
</span><span id="line-481"></span><span class="hs-comment">-- A number of operations return information about the properties of a</span><span>
</span><span id="line-482"></span><span class="hs-comment">-- handle.  Each of these operations returns `True' if the handle has</span><span>
</span><span id="line-483"></span><span class="hs-comment">-- the specified property, and `False' otherwise.</span><span>
</span><span id="line-484"></span><span>
</span><span id="line-485"></span><span class="annot"><a href="GHC.IO.Handle.html#hIsOpen"><span class="hs-identifier hs-type">hIsOpen</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-486"></span><span id="hIsOpen"><span class="annot"><span class="annottext">hIsOpen :: Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hIsOpen"><span class="hs-identifier hs-var hs-var">hIsOpen</span></a></span></span><span> </span><span id="local-6989586621679555856"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555856"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-487"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hIsOpen&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555856"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Bool) -&gt; IO Bool)
-&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555855"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555855"><span class="hs-identifier hs-var">handle_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-488"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555855"><span class="hs-identifier hs-var">handle_</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-489"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-490"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#SemiClosedHandle"><span class="hs-identifier hs-var">SemiClosedHandle</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-491"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-492"></span><span>
</span><span id="line-493"></span><span class="annot"><a href="GHC.IO.Handle.html#hIsClosed"><span class="hs-identifier hs-type">hIsClosed</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-494"></span><span id="hIsClosed"><span class="annot"><span class="annottext">hIsClosed :: Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hIsClosed"><span class="hs-identifier hs-var hs-var">hIsClosed</span></a></span></span><span> </span><span id="local-6989586621679555854"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555854"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-495"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hIsClosed&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555854"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Bool) -&gt; IO Bool)
-&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555853"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555853"><span class="hs-identifier hs-var">handle_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-496"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555853"><span class="hs-identifier hs-var">handle_</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-497"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-498"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-499"></span><span>
</span><span id="line-500"></span><span class="hs-comment">{- not defined, nor exported, but mentioned
   here for documentation purposes:

    hSemiClosed :: Handle -&gt; IO Bool
    hSemiClosed h = do
       ho &lt;- hIsOpen h
       hc &lt;- hIsClosed h
       return (not (ho || hc))
-}</span><span>
</span><span id="line-509"></span><span>
</span><span id="line-510"></span><span class="annot"><a href="GHC.IO.Handle.html#hIsReadable"><span class="hs-identifier hs-type">hIsReadable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-511"></span><span id="hIsReadable"><span class="annot"><span class="annottext">hIsReadable :: Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hIsReadable"><span class="hs-identifier hs-var hs-var">hIsReadable</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-type">DuplexHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-512"></span><span class="annot"><a href="GHC.IO.Handle.html#hIsReadable"><span class="hs-identifier hs-var">hIsReadable</span></a></span><span> </span><span id="local-6989586621679555852"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555852"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-513"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hIsReadable&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555852"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Bool) -&gt; IO Bool)
-&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555851"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555851"><span class="hs-identifier hs-var">handle_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-514"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555851"><span class="hs-identifier hs-var">handle_</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-515"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Bool
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_closedHandle"><span class="hs-identifier hs-var">ioe_closedHandle</span></a></span><span>
</span><span id="line-516"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#SemiClosedHandle"><span class="hs-identifier hs-var">SemiClosedHandle</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Bool
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_semiclosedHandle"><span class="hs-identifier hs-var">ioe_semiclosedHandle</span></a></span><span>
</span><span id="line-517"></span><span>      </span><span id="local-6989586621679555850"><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555850"><span class="hs-identifier hs-var">htype</span></a></span></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HandleType -&gt; Bool
</span><a href="GHC.IO.Handle.Types.html#isReadableHandleType"><span class="hs-identifier hs-var">isReadableHandleType</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555850"><span class="hs-identifier hs-var">htype</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-518"></span><span>
</span><span id="line-519"></span><span class="annot"><a href="GHC.IO.Handle.html#hIsWritable"><span class="hs-identifier hs-type">hIsWritable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-520"></span><span id="hIsWritable"><span class="annot"><span class="annottext">hIsWritable :: Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hIsWritable"><span class="hs-identifier hs-var hs-var">hIsWritable</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-type">DuplexHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-521"></span><span class="annot"><a href="GHC.IO.Handle.html#hIsWritable"><span class="hs-identifier hs-var">hIsWritable</span></a></span><span> </span><span id="local-6989586621679555849"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555849"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-522"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hIsWritable&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555849"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Bool) -&gt; IO Bool)
-&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555848"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555848"><span class="hs-identifier hs-var">handle_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-523"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555848"><span class="hs-identifier hs-var">handle_</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-524"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Bool
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_closedHandle"><span class="hs-identifier hs-var">ioe_closedHandle</span></a></span><span>
</span><span id="line-525"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#SemiClosedHandle"><span class="hs-identifier hs-var">SemiClosedHandle</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Bool
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_semiclosedHandle"><span class="hs-identifier hs-var">ioe_semiclosedHandle</span></a></span><span>
</span><span id="line-526"></span><span>      </span><span id="local-6989586621679555847"><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555847"><span class="hs-identifier hs-var">htype</span></a></span></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HandleType -&gt; Bool
</span><a href="GHC.IO.Handle.Types.html#isWritableHandleType"><span class="hs-identifier hs-var">isWritableHandleType</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555847"><span class="hs-identifier hs-var">htype</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-527"></span><span>
</span><span id="line-528"></span><span class="hs-comment">-- | Computation 'hGetBuffering' @hdl@ returns the current buffering mode</span><span>
</span><span id="line-529"></span><span class="hs-comment">-- for @hdl@.</span><span>
</span><span id="line-530"></span><span>
</span><span id="line-531"></span><span class="annot"><a href="GHC.IO.Handle.html#hGetBuffering"><span class="hs-identifier hs-type">hGetBuffering</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferMode"><span class="hs-identifier hs-type">BufferMode</span></a></span><span>
</span><span id="line-532"></span><span id="hGetBuffering"><span class="annot"><span class="annottext">hGetBuffering :: Handle -&gt; IO BufferMode
</span><a href="GHC.IO.Handle.html#hGetBuffering"><span class="hs-identifier hs-var hs-var">hGetBuffering</span></a></span></span><span> </span><span id="local-6989586621679555845"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555845"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-533"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO BufferMode) -&gt; IO BufferMode
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetBuffering&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555845"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO BufferMode) -&gt; IO BufferMode)
-&gt; (Handle__ -&gt; IO BufferMode) -&gt; IO BufferMode
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555844"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555844"><span class="hs-identifier hs-var">handle_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-534"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555844"><span class="hs-identifier hs-var">handle_</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-535"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO BufferMode
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_closedHandle"><span class="hs-identifier hs-var">ioe_closedHandle</span></a></span><span>
</span><span id="line-536"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-537"></span><span>           </span><span class="hs-comment">-- We're being non-standard here, and allow the buffering</span><span>
</span><span id="line-538"></span><span>           </span><span class="hs-comment">-- of a semi-closed handle to be queried.   -- sof 6/98</span><span>
</span><span id="line-539"></span><span>          </span><span class="annot"><span class="annottext">BufferMode -&gt; IO BufferMode
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__ -&gt; BufferMode
</span><a href="GHC.IO.Handle.Types.html#haBufferMode"><span class="hs-identifier hs-var hs-var">haBufferMode</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555844"><span class="hs-identifier hs-var">handle_</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- could be stricter..</span><span>
</span><span id="line-540"></span><span>
</span><span id="line-541"></span><span class="annot"><a href="GHC.IO.Handle.html#hIsSeekable"><span class="hs-identifier hs-type">hIsSeekable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-542"></span><span id="hIsSeekable"><span class="annot"><span class="annottext">hIsSeekable :: Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hIsSeekable"><span class="hs-identifier hs-var hs-var">hIsSeekable</span></a></span></span><span> </span><span id="local-6989586621679555843"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555843"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-543"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hIsSeekable&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555843"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Bool) -&gt; IO Bool)
-&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555842"><span class="annot"><span class="annottext">handle_ :: Handle__
</span><a href="#local-6989586621679555842"><span class="hs-identifier hs-var">handle_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679555823"><span id="local-6989586621679555824"><span id="local-6989586621679555825"><span id="local-6989586621679555826"><span id="local-6989586621679555827"><span id="local-6989586621679555828"><span id="local-6989586621679555829"><span id="local-6989586621679555830"><span id="local-6989586621679555831"><span id="local-6989586621679555832"><span id="local-6989586621679555833"><span id="local-6989586621679555834"><span id="local-6989586621679555835"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679555823"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-544"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555834"><span class="hs-identifier hs-var">haType</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-545"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Bool
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_closedHandle"><span class="hs-identifier hs-var">ioe_closedHandle</span></a></span><span>
</span><span id="line-546"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#SemiClosedHandle"><span class="hs-identifier hs-var">SemiClosedHandle</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Bool
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_semiclosedHandle"><span class="hs-identifier hs-var">ioe_semiclosedHandle</span></a></span><span>
</span><span id="line-547"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#AppendHandle"><span class="hs-identifier hs-var">AppendHandle</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-548"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">dev -&gt; IO Bool
forall a. IODevice a =&gt; a -&gt; IO Bool
</span><a href="GHC.IO.Device.html#isSeekable"><span class="hs-identifier hs-var">IODevice.isSeekable</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555835"><span class="hs-identifier hs-var">haDevice</span></a></span><span>
</span><span id="line-549"></span><span>
</span><span id="line-550"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-551"></span><span class="hs-comment">-- Changing echo status</span><span>
</span><span id="line-552"></span><span>
</span><span id="line-553"></span><span class="hs-comment">-- | Set the echoing status of a handle connected to a terminal.</span><span>
</span><span id="line-554"></span><span>
</span><span id="line-555"></span><span class="annot"><a href="GHC.IO.Handle.html#hSetEcho"><span class="hs-identifier hs-type">hSetEcho</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-556"></span><span id="hSetEcho"><span class="annot"><span class="annottext">hSetEcho :: Handle -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hSetEcho"><span class="hs-identifier hs-var hs-var">hSetEcho</span></a></span></span><span> </span><span id="local-6989586621679555820"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555820"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span id="local-6989586621679555819"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555819"><span class="hs-identifier hs-var">on</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-557"></span><span>    </span><span id="local-6989586621679555818"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555818"><span class="hs-identifier hs-var">isT</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hIsTerminalDevice"><span class="hs-identifier hs-var">hIsTerminalDevice</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555820"><span class="hs-identifier hs-var">handle</span></a></span><span>
</span><span id="line-558"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#not"><span class="hs-identifier hs-var">not</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555818"><span class="hs-identifier hs-var">isT</span></a></span><span>
</span><span id="line-559"></span><span>     </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-560"></span><span>     </span><span class="hs-keyword">else</span><span>
</span><span id="line-561"></span><span>      </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO ()) -&gt; IO ()
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSetEcho&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555820"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO ()) -&gt; IO ()) -&gt; (Handle__ -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679555800"><span id="local-6989586621679555801"><span id="local-6989586621679555802"><span id="local-6989586621679555803"><span id="local-6989586621679555804"><span id="local-6989586621679555805"><span id="local-6989586621679555806"><span id="local-6989586621679555807"><span id="local-6989586621679555808"><span id="local-6989586621679555809"><span id="local-6989586621679555810"><span id="local-6989586621679555811"><span id="local-6989586621679555812"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679555800"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-562"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555811"><span class="hs-identifier hs-var">haType</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-563"></span><span>         </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO ()
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_closedHandle"><span class="hs-identifier hs-var">ioe_closedHandle</span></a></span><span>
</span><span id="line-564"></span><span>         </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">dev -&gt; Bool -&gt; IO ()
forall a. IODevice a =&gt; a -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.Device.html#setEcho"><span class="hs-identifier hs-var">IODevice.setEcho</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555812"><span class="hs-identifier hs-var">haDevice</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555819"><span class="hs-identifier hs-var">on</span></a></span><span>
</span><span id="line-565"></span><span>
</span><span id="line-566"></span><span class="hs-comment">-- | Get the echoing status of a handle connected to a terminal.</span><span>
</span><span id="line-567"></span><span>
</span><span id="line-568"></span><span class="annot"><a href="GHC.IO.Handle.html#hGetEcho"><span class="hs-identifier hs-type">hGetEcho</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-569"></span><span id="hGetEcho"><span class="annot"><span class="annottext">hGetEcho :: Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hGetEcho"><span class="hs-identifier hs-var hs-var">hGetEcho</span></a></span></span><span> </span><span id="local-6989586621679555798"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555798"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-570"></span><span>    </span><span id="local-6989586621679555797"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555797"><span class="hs-identifier hs-var">isT</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hIsTerminalDevice"><span class="hs-identifier hs-var">hIsTerminalDevice</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555798"><span class="hs-identifier hs-var">handle</span></a></span><span>
</span><span id="line-571"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#not"><span class="hs-identifier hs-var">not</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555797"><span class="hs-identifier hs-var">isT</span></a></span><span>
</span><span id="line-572"></span><span>     </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-573"></span><span>     </span><span class="hs-keyword">else</span><span>
</span><span id="line-574"></span><span>       </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetEcho&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555798"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Bool) -&gt; IO Bool)
-&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679555779"><span id="local-6989586621679555780"><span id="local-6989586621679555781"><span id="local-6989586621679555782"><span id="local-6989586621679555783"><span id="local-6989586621679555784"><span id="local-6989586621679555785"><span id="local-6989586621679555786"><span id="local-6989586621679555787"><span id="local-6989586621679555788"><span id="local-6989586621679555789"><span id="local-6989586621679555790"><span id="local-6989586621679555791"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679555779"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-575"></span><span>       </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555790"><span class="hs-identifier hs-var">haType</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-576"></span><span>         </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Bool
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_closedHandle"><span class="hs-identifier hs-var">ioe_closedHandle</span></a></span><span>
</span><span id="line-577"></span><span>         </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">dev -&gt; IO Bool
forall a. IODevice a =&gt; a -&gt; IO Bool
</span><a href="GHC.IO.Device.html#getEcho"><span class="hs-identifier hs-var">IODevice.getEcho</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555791"><span class="hs-identifier hs-var">haDevice</span></a></span><span>
</span><span id="line-578"></span><span>
</span><span id="line-579"></span><span class="hs-comment">-- | Is the handle connected to a terminal?</span><span>
</span><span id="line-580"></span><span>
</span><span id="line-581"></span><span class="annot"><a href="GHC.IO.Handle.html#hIsTerminalDevice"><span class="hs-identifier hs-type">hIsTerminalDevice</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-582"></span><span id="hIsTerminalDevice"><span class="annot"><span class="annottext">hIsTerminalDevice :: Handle -&gt; IO Bool
</span><a href="GHC.IO.Handle.html#hIsTerminalDevice"><span class="hs-identifier hs-var hs-var">hIsTerminalDevice</span></a></span></span><span> </span><span id="local-6989586621679555777"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555777"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-583"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hIsTerminalDevice&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555777"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Bool) -&gt; IO Bool)
-&gt; (Handle__ -&gt; IO Bool) -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679555759"><span id="local-6989586621679555760"><span id="local-6989586621679555761"><span id="local-6989586621679555762"><span id="local-6989586621679555763"><span id="local-6989586621679555764"><span id="local-6989586621679555765"><span id="local-6989586621679555766"><span id="local-6989586621679555767"><span id="local-6989586621679555768"><span id="local-6989586621679555769"><span id="local-6989586621679555770"><span id="local-6989586621679555771"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679555759"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-584"></span><span>     </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555770"><span class="hs-identifier hs-var">haType</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-585"></span><span>       </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Bool
forall a. IO a
</span><a href="GHC.IO.Handle.Internals.html#ioe_closedHandle"><span class="hs-identifier hs-var">ioe_closedHandle</span></a></span><span>
</span><span id="line-586"></span><span>       </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">dev -&gt; IO Bool
forall a. IODevice a =&gt; a -&gt; IO Bool
</span><a href="GHC.IO.Device.html#isTerminal"><span class="hs-identifier hs-var">IODevice.isTerminal</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555771"><span class="hs-identifier hs-var">haDevice</span></a></span><span>
</span><span id="line-587"></span><span>
</span><span id="line-588"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-589"></span><span class="hs-comment">-- hSetBinaryMode</span><span>
</span><span id="line-590"></span><span>
</span><span id="line-591"></span><span class="hs-comment">-- | Select binary mode ('True') or text mode ('False') on a open handle.</span><span>
</span><span id="line-592"></span><span class="hs-comment">-- (See also 'openBinaryFile'.)</span><span>
</span><span id="line-593"></span><span class="hs-comment">--</span><span>
</span><span id="line-594"></span><span class="hs-comment">-- This has the same effect as calling 'hSetEncoding' with 'char8', together</span><span>
</span><span id="line-595"></span><span class="hs-comment">-- with 'hSetNewlineMode' with 'noNewlineTranslation'.</span><span>
</span><span id="line-596"></span><span class="hs-comment">--</span><span>
</span><span id="line-597"></span><span class="annot"><a href="GHC.IO.Handle.html#hSetBinaryMode"><span class="hs-identifier hs-type">hSetBinaryMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-598"></span><span id="hSetBinaryMode"><span class="annot"><span class="annottext">hSetBinaryMode :: Handle -&gt; Bool -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hSetBinaryMode"><span class="hs-identifier hs-var hs-var">hSetBinaryMode</span></a></span></span><span> </span><span id="local-6989586621679555758"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555758"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span id="local-6989586621679555757"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555757"><span class="hs-identifier hs-var">bin</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-599"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#withAllHandles__"><span class="hs-identifier hs-var">withAllHandles__</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSetBinaryMode&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555758"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle__) -&gt; IO ())
-&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555756"><span class="annot"><span class="annottext">h_ :: Handle__
</span><a href="#local-6989586621679555756"><span class="hs-identifier hs-var">h_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679555734"><span id="local-6989586621679555735"><span id="local-6989586621679555736"><span id="local-6989586621679555737"><span id="local-6989586621679555738"><span id="local-6989586621679555739"><span id="local-6989586621679555740"><span id="local-6989586621679555741"><span id="local-6989586621679555742"><span id="local-6989586621679555743"><span id="local-6989586621679555744"><span id="local-6989586621679555745"><span id="local-6989586621679555746"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679555734"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-600"></span><span>    </span><span class="hs-keyword">do</span><span>
</span><span id="line-601"></span><span>         </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushCharBuffer"><span class="hs-identifier hs-var">flushCharBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555756"><span class="hs-identifier hs-var">h_</span></a></span><span>
</span><span id="line-602"></span><span>         </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#closeTextCodecs"><span class="hs-identifier hs-var">closeTextCodecs</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555756"><span class="hs-identifier hs-var">h_</span></a></span><span>
</span><span id="line-603"></span><span>
</span><span id="line-604"></span><span>         </span><span id="local-6989586621679555733"><span class="annot"><span class="annottext">Maybe TextEncoding
</span><a href="#local-6989586621679555733"><span class="hs-identifier hs-var">mb_te</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555757"><span class="hs-identifier hs-var">bin</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe TextEncoding -&gt; IO (Maybe TextEncoding)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TextEncoding
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-605"></span><span>                         </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; Maybe TextEncoding)
-&gt; IO TextEncoding -&gt; IO (Maybe TextEncoding)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; Maybe TextEncoding
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">IO TextEncoding
</span><a href="GHC.IO.Encoding.html#getLocaleEncoding"><span class="hs-identifier hs-var">getLocaleEncoding</span></a></span><span>
</span><span id="line-606"></span><span>
</span><span id="line-607"></span><span>         </span><span class="annot"><span class="annottext">Maybe TextEncoding
-&gt; HandleType
-&gt; (forall es ds.
    Maybe (TextEncoder es) -&gt; Maybe (TextDecoder ds) -&gt; IO Handle__)
-&gt; IO Handle__
forall a.
Maybe TextEncoding
-&gt; HandleType
-&gt; (forall es ds.
    Maybe (TextEncoder es) -&gt; Maybe (TextDecoder ds) -&gt; IO a)
-&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#openTextEncoding"><span class="hs-identifier hs-var">openTextEncoding</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TextEncoding
</span><a href="#local-6989586621679555733"><span class="hs-identifier hs-var">mb_te</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555745"><span class="hs-identifier hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">((forall es ds.
  Maybe (TextEncoder es) -&gt; Maybe (TextDecoder ds) -&gt; IO Handle__)
 -&gt; IO Handle__)
-&gt; (forall es ds.
    Maybe (TextEncoder es) -&gt; Maybe (TextDecoder ds) -&gt; IO Handle__)
-&gt; IO Handle__
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679555724"><span class="annot"><span class="annottext">Maybe (TextEncoder es)
</span><a href="#local-6989586621679555724"><span class="hs-identifier hs-var">mb_encoder</span></a></span></span><span> </span><span id="local-6989586621679555723"><span class="annot"><span class="annottext">Maybe (TextDecoder ds)
</span><a href="#local-6989586621679555723"><span class="hs-identifier hs-var">mb_decoder</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-608"></span><span>
</span><span id="line-609"></span><span>         </span><span class="hs-comment">-- should match the default newline mode, whatever that is</span><span>
</span><span id="line-610"></span><span>         </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679555722"><span class="annot"><span class="annottext">nl :: NewlineMode
</span><a href="#local-6989586621679555722"><span class="hs-identifier hs-var hs-var">nl</span></a></span></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555757"><span class="hs-identifier hs-var">bin</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NewlineMode
</span><a href="GHC.IO.Handle.Types.html#noNewlineTranslation"><span class="hs-identifier hs-var">noNewlineTranslation</span></a></span><span>
</span><span id="line-611"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NewlineMode
</span><a href="GHC.IO.Handle.Types.html#nativeNewlineMode"><span class="hs-identifier hs-var">nativeNewlineMode</span></a></span><span>
</span><span id="line-612"></span><span>
</span><span id="line-613"></span><span>         </span><span id="local-6989586621679555721"><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555721"><span class="hs-identifier hs-var">bbuf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8) -&gt; IO (Buffer Word8)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer Word8)
</span><a href="#local-6989586621679555744"><span class="hs-identifier hs-var">haByteBuffer</span></a></span><span>
</span><span id="line-614"></span><span>         </span><span id="local-6989586621679555720"><span class="annot"><span class="annottext">IORef (ds, Buffer Word8)
</span><a href="#local-6989586621679555720"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(ds, Buffer Word8) -&gt; IO (IORef (ds, Buffer Word8))
forall a. a -&gt; IO (IORef a)
</span><a href="GHC.IORef.html#newIORef"><span class="hs-identifier hs-var">newIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; ds
forall a. FilePath -&gt; a
</span><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier hs-var">errorWithoutStackTrace</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;codec_state&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679555721"><span class="hs-identifier hs-var">bbuf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-615"></span><span>
</span><span id="line-616"></span><span>         </span><span class="annot"><span class="annottext">Handle__ -&gt; IO Handle__
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ :: forall dev enc_state dec_state.
(RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) =&gt;
dev
-&gt; HandleType
-&gt; IORef (Buffer Word8)
-&gt; BufferMode
-&gt; IORef (dec_state, Buffer Word8)
-&gt; IORef (Buffer CharBufElem)
-&gt; IORef (BufferList CharBufElem)
-&gt; Maybe (TextEncoder enc_state)
-&gt; Maybe (TextDecoder dec_state)
-&gt; Maybe TextEncoding
-&gt; Newline
-&gt; Newline
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
</span><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">haLastDecode :: IORef (ds, Buffer Word8)
</span><a href="GHC.IO.Handle.Types.html#haLastDecode"><span class="hs-identifier hs-var">haLastDecode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef (ds, Buffer Word8)
</span><a href="#local-6989586621679555720"><span class="hs-identifier hs-var">ref</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-617"></span><span>                          </span><span class="annot"><span class="annottext">haEncoder :: Maybe (TextEncoder es)
</span><a href="GHC.IO.Handle.Types.html#haEncoder"><span class="hs-identifier hs-var">haEncoder</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (TextEncoder es)
</span><a href="#local-6989586621679555724"><span class="hs-identifier hs-var">mb_encoder</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-618"></span><span>                          </span><span class="annot"><span class="annottext">haDecoder :: Maybe (TextDecoder ds)
</span><a href="GHC.IO.Handle.Types.html#haDecoder"><span class="hs-identifier hs-var">haDecoder</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (TextDecoder ds)
</span><a href="#local-6989586621679555723"><span class="hs-identifier hs-var">mb_decoder</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-619"></span><span>                          </span><span class="annot"><span class="annottext">haCodec :: Maybe TextEncoding
</span><a href="GHC.IO.Handle.Types.html#haCodec"><span class="hs-identifier hs-var">haCodec</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe TextEncoding
</span><a href="#local-6989586621679555733"><span class="hs-identifier hs-var">mb_te</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-620"></span><span>                          </span><span class="annot"><span class="annottext">haInputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#haInputNL"><span class="hs-identifier hs-var">haInputNL</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NewlineMode -&gt; Newline
</span><a href="GHC.IO.Handle.Types.html#inputNL"><span class="hs-identifier hs-var hs-var">inputNL</span></a></span><span> </span><span class="annot"><span class="annottext">NewlineMode
</span><a href="#local-6989586621679555722"><span class="hs-identifier hs-var">nl</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-621"></span><span>                          </span><span class="annot"><span class="annottext">haOutputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#haOutputNL"><span class="hs-identifier hs-var">haOutputNL</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NewlineMode -&gt; Newline
</span><a href="GHC.IO.Handle.Types.html#outputNL"><span class="hs-identifier hs-var hs-var">outputNL</span></a></span><span> </span><span class="annot"><span class="annottext">NewlineMode
</span><a href="#local-6989586621679555722"><span class="hs-identifier hs-var">nl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
haOtherSide :: Maybe (MVar Handle__)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOtherSide :: Maybe (MVar Handle__)
haCharBuffer :: IORef (Buffer CharBufElem)
haByteBuffer :: IORef (Buffer Word8)
haBuffers :: IORef (BufferList CharBufElem)
haBufferMode :: BufferMode
haType :: HandleType
haDevice :: dev
</span><a href="#local-6989586621679555734"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-622"></span><span>
</span><span id="line-623"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-624"></span><span class="hs-comment">-- hSetNewlineMode</span><span>
</span><span id="line-625"></span><span>
</span><span id="line-626"></span><span class="hs-comment">-- | Set the 'NewlineMode' on the specified 'Handle'.  All buffered</span><span>
</span><span id="line-627"></span><span class="hs-comment">-- data is flushed first.</span><span>
</span><span id="line-628"></span><span class="annot"><a href="GHC.IO.Handle.html#hSetNewlineMode"><span class="hs-identifier hs-type">hSetNewlineMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-type">NewlineMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-629"></span><span id="hSetNewlineMode"><span class="annot"><span class="annottext">hSetNewlineMode :: Handle -&gt; NewlineMode -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hSetNewlineMode"><span class="hs-identifier hs-var hs-var">hSetNewlineMode</span></a></span></span><span> </span><span id="local-6989586621679555717"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555717"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-type">NewlineMode</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">inputNL :: NewlineMode -&gt; Newline
</span><a href="GHC.IO.Handle.Types.html#inputNL"><span class="hs-identifier hs-var">inputNL</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679555715"><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679555715"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">outputNL :: NewlineMode -&gt; Newline
</span><a href="GHC.IO.Handle.Types.html#outputNL"><span class="hs-identifier hs-var">outputNL</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679555714"><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679555714"><span class="hs-identifier hs-var">o</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-630"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#withAllHandles__"><span class="hs-identifier hs-var">withAllHandles__</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hSetNewlineMode&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555717"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle__) -&gt; IO ())
-&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555713"><span class="annot"><span class="annottext">h_ :: Handle__
</span><a href="#local-6989586621679555713"><span class="hs-identifier hs-var">h_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-631"></span><span>    </span><span class="hs-keyword">do</span><span>
</span><span id="line-632"></span><span>         </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushBuffer"><span class="hs-identifier hs-var">flushBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555713"><span class="hs-identifier hs-var">h_</span></a></span><span>
</span><span id="line-633"></span><span>         </span><span class="annot"><span class="annottext">Handle__ -&gt; IO Handle__
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555713"><span class="hs-identifier hs-var">h_</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">haInputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#haInputNL"><span class="hs-identifier hs-var">haInputNL</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679555715"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">haOutputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#haOutputNL"><span class="hs-identifier hs-var">haOutputNL</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679555714"><span class="hs-identifier hs-var">o</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-634"></span><span>
</span><span id="line-635"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-636"></span><span class="hs-comment">-- Duplicating a Handle</span><span>
</span><span id="line-637"></span><span>
</span><span id="line-638"></span><span class="hs-comment">-- | Returns a duplicate of the original handle, with its own buffer.</span><span>
</span><span id="line-639"></span><span class="hs-comment">-- The two Handles will share a file pointer, however.  The original</span><span>
</span><span id="line-640"></span><span class="hs-comment">-- handle's buffer is flushed, including discarding any input data,</span><span>
</span><span id="line-641"></span><span class="hs-comment">-- before the handle is duplicated.</span><span>
</span><span id="line-642"></span><span>
</span><span id="line-643"></span><span class="annot"><a href="GHC.IO.Handle.html#hDuplicate"><span class="hs-identifier hs-type">hDuplicate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-644"></span><span id="hDuplicate"><span class="annot"><span class="annottext">hDuplicate :: Handle -&gt; IO Handle
</span><a href="GHC.IO.Handle.html#hDuplicate"><span class="hs-identifier hs-var hs-var">hDuplicate</span></a></span></span><span> </span><span id="local-6989586621679555706"><span class="annot"><span class="annottext">h :: Handle
</span><a href="#local-6989586621679555706"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span> </span><span id="local-6989586621679555705"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555705"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621679555704"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555704"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-645"></span><span>  </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO Handle) -&gt; IO Handle
forall a.
FilePath -&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_%27"><span class="hs-identifier hs-var">withHandle_'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hDuplicate&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555706"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555704"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle) -&gt; IO Handle)
-&gt; (Handle__ -&gt; IO Handle) -&gt; IO Handle
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555702"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555702"><span class="hs-identifier hs-var">h_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-646"></span><span>      </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
</span><a href="GHC.IO.Handle.html#dupHandle"><span class="hs-identifier hs-var">dupHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555705"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555706"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (MVar Handle__)
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555702"><span class="hs-identifier hs-var">h_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HandleFinalizer -&gt; Maybe HandleFinalizer
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">HandleFinalizer
</span><a href="GHC.IO.Handle.Internals.html#handleFinalizer"><span class="hs-identifier hs-var">handleFinalizer</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-647"></span><span class="annot"><a href="GHC.IO.Handle.html#hDuplicate"><span class="hs-identifier hs-var">hDuplicate</span></a></span><span> </span><span id="local-6989586621679555699"><span class="annot"><span class="annottext">h :: Handle
</span><a href="#local-6989586621679555699"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-type">DuplexHandle</span></a></span><span> </span><span id="local-6989586621679555698"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555698"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621679555697"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555697"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621679555696"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555696"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-648"></span><span>  </span><span id="local-6989586621679555695"><span class="annot"><span class="annottext">write_side :: Handle
</span><a href="#local-6989586621679555695"><span class="hs-identifier hs-var">write_side</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679555694"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555694"><span class="hs-identifier hs-var">write_m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-649"></span><span>     </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO Handle) -&gt; IO Handle
forall a.
FilePath -&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_%27"><span class="hs-identifier hs-var">withHandle_'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hDuplicate&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555699"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555696"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle) -&gt; IO Handle)
-&gt; (Handle__ -&gt; IO Handle) -&gt; IO Handle
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555693"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555693"><span class="hs-identifier hs-var">h_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-650"></span><span>        </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
</span><a href="GHC.IO.Handle.html#dupHandle"><span class="hs-identifier hs-var">dupHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555698"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555699"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (MVar Handle__)
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555693"><span class="hs-identifier hs-var">h_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HandleFinalizer -&gt; Maybe HandleFinalizer
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">HandleFinalizer
</span><a href="GHC.IO.Handle.Internals.html#handleFinalizer"><span class="hs-identifier hs-var">handleFinalizer</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-651"></span><span>  </span><span id="local-6989586621679555692"><span class="annot"><span class="annottext">read_side :: Handle
</span><a href="#local-6989586621679555692"><span class="hs-identifier hs-var">read_side</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679555691"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555691"><span class="hs-identifier hs-var">read_m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-652"></span><span>    </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO Handle) -&gt; IO Handle
forall a.
FilePath -&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_%27"><span class="hs-identifier hs-var">withHandle_'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hDuplicate&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555699"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555697"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle) -&gt; IO Handle)
-&gt; (Handle__ -&gt; IO Handle) -&gt; IO Handle
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555690"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555690"><span class="hs-identifier hs-var">h_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-653"></span><span>        </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
</span><a href="GHC.IO.Handle.html#dupHandle"><span class="hs-identifier hs-var">dupHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555698"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555699"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MVar Handle__ -&gt; Maybe (MVar Handle__)
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555694"><span class="hs-identifier hs-var">write_m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555690"><span class="hs-identifier hs-var">h_</span></a></span><span>  </span><span class="annot"><span class="annottext">Maybe HandleFinalizer
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-654"></span><span>  </span><span class="annot"><span class="annottext">Handle -&gt; IO Handle
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; MVar Handle__ -&gt; MVar Handle__ -&gt; Handle
</span><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-var">DuplexHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555698"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555691"><span class="hs-identifier hs-var">read_m</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555694"><span class="hs-identifier hs-var">write_m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-655"></span><span>
</span><span id="line-656"></span><span class="annot"><a href="GHC.IO.Handle.html#dupHandle"><span class="hs-identifier hs-type">dupHandle</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-657"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-658"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-659"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span>
</span><span id="line-660"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Internals.html#HandleFinalizer"><span class="hs-identifier hs-type">HandleFinalizer</span></a></span><span>
</span><span id="line-661"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-662"></span><span id="dupHandle"><span class="annot"><span class="annottext">dupHandle :: FilePath
-&gt; Handle
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
</span><a href="GHC.IO.Handle.html#dupHandle"><span class="hs-identifier hs-var hs-var">dupHandle</span></a></span></span><span> </span><span id="local-6989586621679555689"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555689"><span class="hs-identifier hs-var">filepath</span></a></span></span><span> </span><span id="local-6989586621679555688"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555688"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679555687"><span class="annot"><span class="annottext">Maybe (MVar Handle__)
</span><a href="#local-6989586621679555687"><span class="hs-identifier hs-var">other_side</span></a></span></span><span> </span><span id="local-6989586621679555686"><span class="annot"><span class="annottext">h_ :: Handle__
</span><a href="#local-6989586621679555686"><span class="hs-identifier hs-var">h_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679555662"><span id="local-6989586621679555663"><span id="local-6989586621679555664"><span id="local-6989586621679555665"><span id="local-6989586621679555666"><span id="local-6989586621679555667"><span id="local-6989586621679555668"><span id="local-6989586621679555669"><span id="local-6989586621679555670"><span id="local-6989586621679555671"><span id="local-6989586621679555672"><span id="local-6989586621679555673"><span id="local-6989586621679555674"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679555662"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span id="local-6989586621679555661"><span class="annot"><span class="annottext">Maybe HandleFinalizer
</span><a href="#local-6989586621679555661"><span class="hs-identifier hs-var">mb_finalizer</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-663"></span><span>  </span><span class="hs-comment">-- flush the buffer first, so we don't have to copy its contents</span><span>
</span><span id="line-664"></span><span>  </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushBuffer"><span class="hs-identifier hs-var">flushBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555686"><span class="hs-identifier hs-var">h_</span></a></span><span>
</span><span id="line-665"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (MVar Handle__)
</span><a href="#local-6989586621679555687"><span class="hs-identifier hs-var">other_side</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-666"></span><span>    </span><span class="annot"><span class="annottext">Maybe (MVar Handle__)
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-667"></span><span>       </span><span id="local-6989586621679555660"><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555660"><span class="hs-identifier hs-var">new_dev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">dev -&gt; IO dev
forall a. IODevice a =&gt; a -&gt; IO a
</span><a href="GHC.IO.Device.html#dup"><span class="hs-identifier hs-var">IODevice.dup</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555674"><span class="hs-identifier hs-var">haDevice</span></a></span><span>
</span><span id="line-668"></span><span>       </span><span class="annot"><span class="annottext">dev
-&gt; FilePath
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
forall dev.
(RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) =&gt;
dev
-&gt; FilePath
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
</span><a href="GHC.IO.Handle.html#dupHandle_"><span class="hs-identifier hs-var">dupHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555660"><span class="hs-identifier hs-var">new_dev</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555689"><span class="hs-identifier hs-var">filepath</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (MVar Handle__)
</span><a href="#local-6989586621679555687"><span class="hs-identifier hs-var">other_side</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555686"><span class="hs-identifier hs-var">h_</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe HandleFinalizer
</span><a href="#local-6989586621679555661"><span class="hs-identifier hs-var">mb_finalizer</span></a></span><span>
</span><span id="line-669"></span><span>    </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679555657"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555657"><span class="hs-identifier hs-var">r</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-670"></span><span>       </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO Handle) -&gt; IO Handle
forall a.
FilePath -&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_%27"><span class="hs-identifier hs-var">withHandle_'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;dupHandle&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555688"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555657"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle) -&gt; IO Handle)
-&gt; (Handle__ -&gt; IO Handle) -&gt; IO Handle
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">haDevice :: ()
</span><a href="GHC.IO.Handle.Types.html#haDevice"><span class="hs-identifier hs-var">haDevice</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679555648"><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555648"><span class="hs-identifier hs-var">dev</span></a></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-671"></span><span>         </span><span class="annot"><span class="annottext">dev
-&gt; FilePath
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
forall dev.
(RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) =&gt;
dev
-&gt; FilePath
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
</span><a href="GHC.IO.Handle.html#dupHandle_"><span class="hs-identifier hs-var">dupHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555648"><span class="hs-identifier hs-var">dev</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555689"><span class="hs-identifier hs-var">filepath</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (MVar Handle__)
</span><a href="#local-6989586621679555687"><span class="hs-identifier hs-var">other_side</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555686"><span class="hs-identifier hs-var">h_</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe HandleFinalizer
</span><a href="#local-6989586621679555661"><span class="hs-identifier hs-var">mb_finalizer</span></a></span><span>
</span><span id="line-672"></span><span>
</span><span id="line-673"></span><span id="local-6989586621679556402"><span class="annot"><a href="GHC.IO.Handle.html#dupHandle_"><span class="hs-identifier hs-type">dupHandle_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Device.html#RawIO"><span class="hs-identifier hs-type">RawIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679556402"><span class="hs-identifier hs-type">dev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Device.html#IODevice"><span class="hs-identifier hs-type">IODevice</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679556402"><span class="hs-identifier hs-type">dev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.BufferedIO.html#BufferedIO"><span class="hs-identifier hs-type">BufferedIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679556402"><span class="hs-identifier hs-type">dev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679556402"><span class="hs-identifier hs-type">dev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679556402"><span class="hs-identifier hs-type">dev</span></a></span><span>
</span><span id="line-674"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-675"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-676"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span>
</span><span id="line-677"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Internals.html#HandleFinalizer"><span class="hs-identifier hs-type">HandleFinalizer</span></a></span><span>
</span><span id="line-678"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span></span><span>
</span><span id="line-679"></span><span id="dupHandle_"><span class="annot"><span class="annottext">dupHandle_ :: forall dev.
(RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) =&gt;
dev
-&gt; FilePath
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
</span><a href="GHC.IO.Handle.html#dupHandle_"><span class="hs-identifier hs-var hs-var">dupHandle_</span></a></span></span><span> </span><span id="local-6989586621679555643"><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555643"><span class="hs-identifier hs-var">new_dev</span></a></span></span><span> </span><span id="local-6989586621679555642"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555642"><span class="hs-identifier hs-var">filepath</span></a></span></span><span> </span><span id="local-6989586621679555641"><span class="annot"><span class="annottext">Maybe (MVar Handle__)
</span><a href="#local-6989586621679555641"><span class="hs-identifier hs-var">other_side</span></a></span></span><span> </span><span id="local-6989586621679555640"><span class="annot"><span class="annottext">h_ :: Handle__
</span><a href="#local-6989586621679555640"><span class="hs-identifier hs-var">h_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679555616"><span id="local-6989586621679555617"><span id="local-6989586621679555618"><span id="local-6989586621679555619"><span id="local-6989586621679555620"><span id="local-6989586621679555621"><span id="local-6989586621679555622"><span id="local-6989586621679555623"><span id="local-6989586621679555624"><span id="local-6989586621679555625"><span id="local-6989586621679555626"><span id="local-6989586621679555627"><span id="local-6989586621679555628"><span class="annot"><span class="annottext">dev
Maybe (MVar Handle__)
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe TextEncoding
IORef (dec_state, Buffer Word8)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
IORef (BufferList CharBufElem)
BufferMode
HandleType
Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haLastDecode :: ()
haInputNL :: Handle__ -&gt; Newline
haEncoder :: ()
haDecoder :: ()
haCodec :: Handle__ -&gt; Maybe TextEncoding
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haBufferMode :: Handle__ -&gt; BufferMode
haType :: Handle__ -&gt; HandleType
haDevice :: ()
</span><a href="#local-6989586621679555616"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span id="local-6989586621679555615"><span class="annot"><span class="annottext">Maybe HandleFinalizer
</span><a href="#local-6989586621679555615"><span class="hs-identifier hs-var">mb_finalizer</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-680"></span><span>   </span><span class="hs-comment">-- XXX wrong!</span><span>
</span><span id="line-681"></span><span>  </span><span id="local-6989586621679555614"><span class="annot"><span class="annottext">Maybe TextEncoding
</span><a href="#local-6989586621679555614"><span class="hs-identifier hs-var">mb_codec</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Maybe (TextEncoder enc_state) -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (TextEncoder enc_state)
</span><a href="#local-6989586621679555621"><span class="hs-identifier hs-var">haEncoder</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; Maybe TextEncoding)
-&gt; IO TextEncoding -&gt; IO (Maybe TextEncoding)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; Maybe TextEncoding
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">IO TextEncoding
</span><a href="GHC.IO.Encoding.html#getLocaleEncoding"><span class="hs-identifier hs-var">getLocaleEncoding</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe TextEncoding -&gt; IO (Maybe TextEncoding)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TextEncoding
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-682"></span><span>  </span><span class="annot"><span class="annottext">dev
-&gt; FilePath
-&gt; HandleType
-&gt; Bool
-&gt; Maybe TextEncoding
-&gt; NewlineMode
-&gt; Maybe HandleFinalizer
-&gt; Maybe (MVar Handle__)
-&gt; IO Handle
forall dev.
(RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) =&gt;
dev
-&gt; FilePath
-&gt; HandleType
-&gt; Bool
-&gt; Maybe TextEncoding
-&gt; NewlineMode
-&gt; Maybe HandleFinalizer
-&gt; Maybe (MVar Handle__)
-&gt; IO Handle
</span><a href="GHC.IO.Handle.Internals.html#mkHandle"><span class="hs-identifier hs-var">mkHandle</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555643"><span class="hs-identifier hs-var">new_dev</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555642"><span class="hs-identifier hs-var">filepath</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555627"><span class="hs-identifier hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-comment">{-buffered-}</span><span> </span><span class="annot"><span class="annottext">Maybe TextEncoding
</span><a href="#local-6989586621679555614"><span class="hs-identifier hs-var">mb_codec</span></a></span><span>
</span><span id="line-683"></span><span>      </span><span class="annot"><span class="annottext">NewlineMode :: Newline -&gt; Newline -&gt; NewlineMode
</span><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-type">NewlineMode</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">inputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#inputNL"><span class="hs-identifier hs-var">inputNL</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679555618"><span class="hs-identifier hs-var">haInputNL</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">outputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#outputNL"><span class="hs-identifier hs-var">outputNL</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679555617"><span class="hs-identifier hs-var">haOutputNL</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-684"></span><span>      </span><span class="annot"><span class="annottext">Maybe HandleFinalizer
</span><a href="#local-6989586621679555615"><span class="hs-identifier hs-var">mb_finalizer</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (MVar Handle__)
</span><a href="#local-6989586621679555641"><span class="hs-identifier hs-var">other_side</span></a></span><span>
</span><span id="line-685"></span><span>
</span><span id="line-686"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-687"></span><span class="hs-comment">-- Replacing a Handle</span><span>
</span><span id="line-688"></span><span>
</span><span id="line-689"></span><span class="hs-comment">{- |
Makes the second handle a duplicate of the first handle.  The second
handle will be closed first, if it is not already.

This can be used to retarget the standard Handles, for example:

&gt; do h &lt;- openFile &quot;mystdout&quot; WriteMode
&gt;    hDuplicateTo h stdout
-}</span><span>
</span><span id="line-698"></span><span>
</span><span id="line-699"></span><span class="annot"><a href="GHC.IO.Handle.html#hDuplicateTo"><span class="hs-identifier hs-type">hDuplicateTo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-700"></span><span id="hDuplicateTo"><span class="annot"><span class="annottext">hDuplicateTo :: Handle -&gt; Handle -&gt; IO ()
</span><a href="GHC.IO.Handle.html#hDuplicateTo"><span class="hs-identifier hs-var hs-var">hDuplicateTo</span></a></span></span><span> </span><span id="local-6989586621679555611"><span class="annot"><span class="annottext">h1 :: Handle
</span><a href="#local-6989586621679555611"><span class="hs-identifier hs-var">h1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span> </span><span id="local-6989586621679555610"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555610"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621679555609"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555609"><span class="hs-identifier hs-var">m1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679555608"><span class="annot"><span class="annottext">h2 :: Handle
</span><a href="#local-6989586621679555608"><span class="hs-identifier hs-var">h2</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679555607"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555607"><span class="hs-identifier hs-var">m2</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-701"></span><span> </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#withHandle__%27"><span class="hs-identifier hs-var">withHandle__'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hDuplicateTo&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555608"><span class="hs-identifier hs-var">h2</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555607"><span class="hs-identifier hs-var">m2</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle__) -&gt; IO ())
-&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555605"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555605"><span class="hs-identifier hs-var">h2_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-702"></span><span>   </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="GHC.IO.Handle.html#try"><span class="hs-identifier hs-var">try</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushWriteBuffer"><span class="hs-identifier hs-var">flushWriteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555605"><span class="hs-identifier hs-var">h2_</span></a></span><span>
</span><span id="line-703"></span><span>   </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; MVar Handle__
-&gt; (Handle__ -&gt; IO Handle__)
-&gt; IO Handle__
forall a.
FilePath -&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_%27"><span class="hs-identifier hs-var">withHandle_'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hDuplicateTo&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555611"><span class="hs-identifier hs-var">h1</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555609"><span class="hs-identifier hs-var">m1</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle__) -&gt; IO Handle__)
-&gt; (Handle__ -&gt; IO Handle__) -&gt; IO Handle__
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555603"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555603"><span class="hs-identifier hs-var">h1_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-704"></span><span>     </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle__
</span><a href="GHC.IO.Handle.html#dupHandleTo"><span class="hs-identifier hs-var">dupHandleTo</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555610"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555611"><span class="hs-identifier hs-var">h1</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (MVar Handle__)
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555605"><span class="hs-identifier hs-var">h2_</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555603"><span class="hs-identifier hs-var">h1_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HandleFinalizer -&gt; Maybe HandleFinalizer
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">HandleFinalizer
</span><a href="GHC.IO.Handle.Internals.html#handleFinalizer"><span class="hs-identifier hs-var">handleFinalizer</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-705"></span><span class="annot"><a href="GHC.IO.Handle.html#hDuplicateTo"><span class="hs-identifier hs-var">hDuplicateTo</span></a></span><span> </span><span id="local-6989586621679555601"><span class="annot"><span class="annottext">h1 :: Handle
</span><a href="#local-6989586621679555601"><span class="hs-identifier hs-var">h1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-type">DuplexHandle</span></a></span><span> </span><span id="local-6989586621679555600"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555600"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621679555599"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555599"><span class="hs-identifier hs-var">r1</span></a></span></span><span> </span><span id="local-6989586621679555598"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555598"><span class="hs-identifier hs-var">w1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679555597"><span class="annot"><span class="annottext">h2 :: Handle
</span><a href="#local-6989586621679555597"><span class="hs-identifier hs-var">h2</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-type">DuplexHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679555596"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555596"><span class="hs-identifier hs-var">r2</span></a></span></span><span> </span><span id="local-6989586621679555595"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555595"><span class="hs-identifier hs-var">w2</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-706"></span><span> </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#withHandle__%27"><span class="hs-identifier hs-var">withHandle__'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hDuplicateTo&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555597"><span class="hs-identifier hs-var">h2</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555595"><span class="hs-identifier hs-var">w2</span></a></span><span>  </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle__) -&gt; IO ())
-&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555594"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555594"><span class="hs-identifier hs-var">w2_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-707"></span><span>   </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="GHC.IO.Handle.html#try"><span class="hs-identifier hs-var">try</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushWriteBuffer"><span class="hs-identifier hs-var">flushWriteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555594"><span class="hs-identifier hs-var">w2_</span></a></span><span>
</span><span id="line-708"></span><span>   </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; MVar Handle__
-&gt; (Handle__ -&gt; IO Handle__)
-&gt; IO Handle__
forall a.
FilePath -&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_%27"><span class="hs-identifier hs-var">withHandle_'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hDuplicateTo&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555601"><span class="hs-identifier hs-var">h1</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555598"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle__) -&gt; IO Handle__)
-&gt; (Handle__ -&gt; IO Handle__) -&gt; IO Handle__
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555593"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555593"><span class="hs-identifier hs-var">w1_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-709"></span><span>     </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle__
</span><a href="GHC.IO.Handle.html#dupHandleTo"><span class="hs-identifier hs-var">dupHandleTo</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555600"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555601"><span class="hs-identifier hs-var">h1</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (MVar Handle__)
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555594"><span class="hs-identifier hs-var">w2_</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555593"><span class="hs-identifier hs-var">w1_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HandleFinalizer -&gt; Maybe HandleFinalizer
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">HandleFinalizer
</span><a href="GHC.IO.Handle.Internals.html#handleFinalizer"><span class="hs-identifier hs-var">handleFinalizer</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-710"></span><span> </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#withHandle__%27"><span class="hs-identifier hs-var">withHandle__'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hDuplicateTo&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555597"><span class="hs-identifier hs-var">h2</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555596"><span class="hs-identifier hs-var">r2</span></a></span><span>  </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle__) -&gt; IO ())
-&gt; (Handle__ -&gt; IO Handle__) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555592"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555592"><span class="hs-identifier hs-var">r2_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-711"></span><span>   </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="GHC.IO.Handle.html#try"><span class="hs-identifier hs-var">try</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushWriteBuffer"><span class="hs-identifier hs-var">flushWriteBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555592"><span class="hs-identifier hs-var">r2_</span></a></span><span>
</span><span id="line-712"></span><span>   </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; MVar Handle__
-&gt; (Handle__ -&gt; IO Handle__)
-&gt; IO Handle__
forall a.
FilePath -&gt; Handle -&gt; MVar Handle__ -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_%27"><span class="hs-identifier hs-var">withHandle_'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hDuplicateTo&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555601"><span class="hs-identifier hs-var">h1</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555599"><span class="hs-identifier hs-var">r1</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO Handle__) -&gt; IO Handle__)
-&gt; (Handle__ -&gt; IO Handle__) -&gt; IO Handle__
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555591"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555591"><span class="hs-identifier hs-var">r1_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-713"></span><span>     </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle__
</span><a href="GHC.IO.Handle.html#dupHandleTo"><span class="hs-identifier hs-var">dupHandleTo</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555600"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555601"><span class="hs-identifier hs-var">h1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MVar Handle__ -&gt; Maybe (MVar Handle__)
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555598"><span class="hs-identifier hs-var">w1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555592"><span class="hs-identifier hs-var">r2_</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555591"><span class="hs-identifier hs-var">r1_</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe HandleFinalizer
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-714"></span><span class="annot"><a href="GHC.IO.Handle.html#hDuplicateTo"><span class="hs-identifier hs-var">hDuplicateTo</span></a></span><span> </span><span id="local-6989586621679555590"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555590"><span class="hs-identifier hs-var">h1</span></a></span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-715"></span><span>  </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
forall a. Handle -&gt; IO a
</span><a href="GHC.IO.Handle.html#ioe_dupHandlesNotCompatible"><span class="hs-identifier hs-var">ioe_dupHandlesNotCompatible</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555590"><span class="hs-identifier hs-var">h1</span></a></span><span>
</span><span id="line-716"></span><span>
</span><span id="line-717"></span><span class="annot"><a href="GHC.IO.Handle.html#try"><span class="hs-identifier hs-type">try</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-718"></span><span id="try"><span class="annot"><span class="annottext">try :: IO () -&gt; IO ()
</span><a href="GHC.IO.Handle.html#try"><span class="hs-identifier hs-var hs-var">try</span></a></span></span><span> </span><span id="local-6989586621679555588"><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679555588"><span class="hs-identifier hs-var">io</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679555588"><span class="hs-identifier hs-var">io</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; (SomeException -&gt; IO ()) -&gt; IO ()
forall e a. Exception e =&gt; IO a -&gt; (e -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.html#catchException"><span class="hs-operator hs-var">`catchException`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO () -&gt; SomeException -&gt; IO ()
forall a b. a -&gt; b -&gt; a
</span><a href="GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Exception.Type.html#SomeException"><span class="hs-identifier hs-type">SomeException</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-719"></span><span>
</span><span id="line-720"></span><span id="local-6989586621679556395"><span class="annot"><a href="GHC.IO.Handle.html#ioe_dupHandlesNotCompatible"><span class="hs-identifier hs-type">ioe_dupHandlesNotCompatible</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679556395"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-721"></span><span id="ioe_dupHandlesNotCompatible"><span class="annot"><span class="annottext">ioe_dupHandlesNotCompatible :: forall a. Handle -&gt; IO a
</span><a href="GHC.IO.Handle.html#ioe_dupHandlesNotCompatible"><span class="hs-identifier hs-var hs-var">ioe_dupHandlesNotCompatible</span></a></span></span><span> </span><span id="local-6989586621679555585"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555585"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-722"></span><span>   </span><span class="annot"><span class="annottext">IOException -&gt; IO a
forall a. IOException -&gt; IO a
</span><a href="GHC.IO.Exception.html#ioException"><span class="hs-identifier hs-var">ioException</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
-&gt; IOErrorType
-&gt; FilePath
-&gt; FilePath
-&gt; Maybe CInt
-&gt; Maybe FilePath
-&gt; IOException
</span><a href="GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-var">IOError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; Maybe Handle
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555585"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="GHC.IO.Exception.html#IllegalOperation"><span class="hs-identifier hs-var">IllegalOperation</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hDuplicateTo&quot;</span></span><span>
</span><span id="line-723"></span><span>                </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;handles are incompatible&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe CInt
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe FilePath
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-724"></span><span>
</span><span id="line-725"></span><span class="annot"><a href="GHC.IO.Handle.html#dupHandleTo"><span class="hs-identifier hs-type">dupHandleTo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-726"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-727"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-728"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span>
</span><span id="line-729"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span>
</span><span id="line-730"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Internals.html#HandleFinalizer"><span class="hs-identifier hs-type">HandleFinalizer</span></a></span><span>
</span><span id="line-731"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span>
</span><span id="line-732"></span><span id="dupHandleTo"><span class="annot"><span class="annottext">dupHandleTo :: FilePath
-&gt; Handle
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle__
</span><a href="GHC.IO.Handle.html#dupHandleTo"><span class="hs-identifier hs-var hs-var">dupHandleTo</span></a></span></span><span> </span><span id="local-6989586621679555583"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555583"><span class="hs-identifier hs-var">filepath</span></a></span></span><span> </span><span id="local-6989586621679555582"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555582"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679555581"><span class="annot"><span class="annottext">Maybe (MVar Handle__)
</span><a href="#local-6989586621679555581"><span class="hs-identifier hs-var">other_side</span></a></span></span><span>
</span><span id="line-733"></span><span>            </span><span id="local-6989586621679555580"><span class="annot"><span class="annottext">hto_ :: Handle__
</span><a href="#local-6989586621679555580"><span class="hs-identifier hs-var">hto_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">haDevice :: ()
</span><a href="GHC.IO.Handle.Types.html#haDevice"><span class="hs-identifier hs-var">haDevice</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679555575"><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555575"><span class="hs-identifier hs-var">devTo</span></a></span></span><span class="hs-special">}</span><span>
</span><span id="line-734"></span><span>            </span><span id="local-6989586621679555574"><span class="annot"><span class="annottext">h_ :: Handle__
</span><a href="#local-6989586621679555574"><span class="hs-identifier hs-var">h_</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">haDevice :: ()
</span><a href="GHC.IO.Handle.Types.html#haDevice"><span class="hs-identifier hs-var">haDevice</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679555558"><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555558"><span class="hs-identifier hs-var">dev</span></a></span></span><span class="hs-special">}</span><span> </span><span id="local-6989586621679555557"><span class="annot"><span class="annottext">Maybe HandleFinalizer
</span><a href="#local-6989586621679555557"><span class="hs-identifier hs-var">mb_finalizer</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-735"></span><span>  </span><span class="annot"><span class="annottext">Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Internals.html#flushBuffer"><span class="hs-identifier hs-var">flushBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555574"><span class="hs-identifier hs-var">h_</span></a></span><span>
</span><span id="line-736"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">dev -&gt; Maybe dev
forall a b. (Typeable a, Typeable b) =&gt; a -&gt; Maybe b
</span><a href="Data.Typeable.html#cast"><span class="hs-identifier hs-var">cast</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555575"><span class="hs-identifier hs-var">devTo</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-737"></span><span>    </span><span class="annot"><span class="annottext">Maybe dev
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Handle__
forall a. Handle -&gt; IO a
</span><a href="GHC.IO.Handle.html#ioe_dupHandlesNotCompatible"><span class="hs-identifier hs-var">ioe_dupHandlesNotCompatible</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555582"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-738"></span><span>    </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679555555"><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555555"><span class="hs-identifier hs-var">dev'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-739"></span><span>      </span><span class="annot"><span class="annottext">dev
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">dev -&gt; dev -&gt; IO dev
forall a. IODevice a =&gt; a -&gt; a -&gt; IO a
</span><a href="GHC.IO.Device.html#dup2"><span class="hs-identifier hs-var">IODevice.dup2</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555558"><span class="hs-identifier hs-var">dev</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555555"><span class="hs-identifier hs-var">dev'</span></a></span><span>
</span><span id="line-740"></span><span>      </span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679555553"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555553"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">dev
-&gt; FilePath
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
forall dev.
(RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) =&gt;
dev
-&gt; FilePath
-&gt; Maybe (MVar Handle__)
-&gt; Handle__
-&gt; Maybe HandleFinalizer
-&gt; IO Handle
</span><a href="GHC.IO.Handle.html#dupHandle_"><span class="hs-identifier hs-var">dupHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">dev
</span><a href="#local-6989586621679555555"><span class="hs-identifier hs-var">dev'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555583"><span class="hs-identifier hs-var">filepath</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (MVar Handle__)
</span><a href="#local-6989586621679555581"><span class="hs-identifier hs-var">other_side</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555574"><span class="hs-identifier hs-var">h_</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe HandleFinalizer
</span><a href="#local-6989586621679555557"><span class="hs-identifier hs-var">mb_finalizer</span></a></span><span>
</span><span id="line-741"></span><span>      </span><span class="annot"><span class="annottext">MVar Handle__ -&gt; IO Handle__
forall a. MVar a -&gt; IO a
</span><a href="GHC.MVar.html#takeMVar"><span class="hs-identifier hs-var">takeMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679555553"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-742"></span><span>
</span><span id="line-743"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-744"></span><span class="hs-comment">-- showing Handles.</span><span>
</span><span id="line-745"></span><span class="hs-comment">--</span><span>
</span><span id="line-746"></span><span class="hs-comment">-- | 'hShow' is in the 'IO' monad, and gives more comprehensive output</span><span>
</span><span id="line-747"></span><span class="hs-comment">-- than the (pure) instance of 'Show' for 'Handle'.</span><span>
</span><span id="line-748"></span><span>
</span><span id="line-749"></span><span class="annot"><a href="GHC.IO.Handle.html#hShow"><span class="hs-identifier hs-type">hShow</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-750"></span><span id="hShow"><span class="annot"><span class="annottext">hShow :: Handle -&gt; IO FilePath
</span><a href="GHC.IO.Handle.html#hShow"><span class="hs-identifier hs-var hs-var">hShow</span></a></span></span><span> </span><span id="local-6989586621679555551"><span class="annot"><span class="annottext">h :: Handle
</span><a href="#local-6989586621679555551"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span> </span><span id="local-6989586621679555550"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555550"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Bool -&gt; Handle -&gt; IO FilePath
</span><a href="GHC.IO.Handle.html#showHandle%27"><span class="hs-identifier hs-var">showHandle'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555550"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555551"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-751"></span><span class="annot"><a href="GHC.IO.Handle.html#hShow"><span class="hs-identifier hs-var">hShow</span></a></span><span> </span><span id="local-6989586621679555548"><span class="annot"><span class="annottext">h :: Handle
</span><a href="#local-6989586621679555548"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-type">DuplexHandle</span></a></span><span> </span><span id="local-6989586621679555547"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555547"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Bool -&gt; Handle -&gt; IO FilePath
</span><a href="GHC.IO.Handle.html#showHandle%27"><span class="hs-identifier hs-var">showHandle'</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555547"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555548"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-752"></span><span>
</span><span id="line-753"></span><span class="annot"><a href="GHC.IO.Handle.html#showHandle%27"><span class="hs-identifier hs-type">showHandle'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-754"></span><span id="showHandle%27"><span class="annot"><span class="annottext">showHandle' :: FilePath -&gt; Bool -&gt; Handle -&gt; IO FilePath
</span><a href="GHC.IO.Handle.html#showHandle%27"><span class="hs-identifier hs-var hs-var">showHandle'</span></a></span></span><span> </span><span id="local-6989586621679555546"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555546"><span class="hs-identifier hs-var">filepath</span></a></span></span><span> </span><span id="local-6989586621679555545"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555545"><span class="hs-identifier hs-var">is_duplex</span></a></span></span><span> </span><span id="local-6989586621679555544"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555544"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-755"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO FilePath) -&gt; IO FilePath
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.Handle.Internals.html#withHandle_"><span class="hs-identifier hs-var">withHandle_</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;showHandle&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679555544"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO FilePath) -&gt; IO FilePath)
-&gt; (Handle__ -&gt; IO FilePath) -&gt; IO FilePath
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679555543"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555543"><span class="hs-identifier hs-var">hdl_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-756"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-757"></span><span>     </span><span id="local-6989586621679555541"><span class="annot"><span class="annottext">showType :: FilePath -&gt; FilePath
</span><a href="#local-6989586621679555541"><span class="hs-identifier hs-var hs-var">showType</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679555545"><span class="hs-identifier hs-var">is_duplex</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;duplex (read-write)&quot;</span></span><span>
</span><span id="line-758"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HandleType -&gt; FilePath -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#shows"><span class="hs-identifier hs-var">shows</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555543"><span class="hs-identifier hs-var">hdl_</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-759"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-760"></span><span>    </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>
</span><span id="line-761"></span><span>      </span><span class="hs-special">(</span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">CharBufElem -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showChar"><span class="hs-identifier hs-var">showChar</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'{'</span></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-762"></span><span>        </span><span class="annot"><span class="annottext">HandleType -&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
</span><a href="#local-6989586621679555539"><span class="hs-identifier hs-var">showHdl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555543"><span class="hs-identifier hs-var">hdl_</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-763"></span><span>            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;loc=&quot;</span></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679555546"><span class="hs-identifier hs-var">filepath</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showChar"><span class="hs-identifier hs-var">showChar</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">','</span></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-764"></span><span>             </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;type=&quot;</span></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="#local-6989586621679555541"><span class="hs-identifier hs-var">showType</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showChar"><span class="hs-identifier hs-var">showChar</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">','</span></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-765"></span><span>             </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;buffering=&quot;</span></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; BufferMode -&gt; FilePath -&gt; FilePath
forall e. Buffer e -&gt; BufferMode -&gt; FilePath -&gt; FilePath
</span><a href="#local-6989586621679555538"><span class="hs-identifier hs-var">showBufMode</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO (Buffer CharBufElem) -&gt; Buffer CharBufElem
forall a. IO a -&gt; a
</span><a href="GHC.IO.Unsafe.html#unsafePerformIO"><span class="hs-identifier hs-var">unsafePerformIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem) -&gt; IO (Buffer CharBufElem)
forall a. IORef a -&gt; IO a
</span><a href="GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__ -&gt; IORef (Buffer CharBufElem)
</span><a href="GHC.IO.Handle.Types.html#haCharBuffer"><span class="hs-identifier hs-var hs-var">haCharBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555543"><span class="hs-identifier hs-var">hdl_</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__ -&gt; BufferMode
</span><a href="GHC.IO.Handle.Types.html#haBufferMode"><span class="hs-identifier hs-var hs-var">haBufferMode</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679555543"><span class="hs-identifier hs-var">hdl_</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;}&quot;</span></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-766"></span><span>      </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-767"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-768"></span><span>
</span><span id="line-769"></span><span>    </span><span class="annot"><a href="#local-6989586621679555539"><span class="hs-identifier hs-type">showHdl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier hs-type">HandleType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Show.html#ShowS"><span class="hs-identifier hs-type">ShowS</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Show.html#ShowS"><span class="hs-identifier hs-type">ShowS</span></a></span><span>
</span><span id="line-770"></span><span>    </span><span id="local-6989586621679555539"><span class="annot"><span class="annottext">showHdl :: HandleType -&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
</span><a href="#local-6989586621679555539"><span class="hs-identifier hs-var hs-var">showHdl</span></a></span></span><span> </span><span id="local-6989586621679555535"><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555535"><span class="hs-identifier hs-var">ht</span></a></span></span><span> </span><span id="local-6989586621679555534"><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="#local-6989586621679555534"><span class="hs-identifier hs-var">cont</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-771"></span><span>       </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555535"><span class="hs-identifier hs-var">ht</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-772"></span><span>        </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">HandleType -&gt; FilePath -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#shows"><span class="hs-identifier hs-var">shows</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679555535"><span class="hs-identifier hs-var">ht</span></a></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;}&quot;</span></span><span>
</span><span id="line-773"></span><span>        </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath
</span><a href="#local-6989586621679555534"><span class="hs-identifier hs-var">cont</span></a></span><span>
</span><span id="line-774"></span><span>
</span><span id="line-775"></span><span>    </span><span id="local-6989586621679556382"><span class="annot"><a href="#local-6989586621679555538"><span class="hs-identifier hs-type">showBufMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679556382"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferMode"><span class="hs-identifier hs-type">BufferMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Show.html#ShowS"><span class="hs-identifier hs-type">ShowS</span></a></span></span><span>
</span><span id="line-776"></span><span>    </span><span id="local-6989586621679555538"><span class="annot"><span class="annottext">showBufMode :: forall e. Buffer e -&gt; BufferMode -&gt; FilePath -&gt; FilePath
</span><a href="#local-6989586621679555538"><span class="hs-identifier hs-var hs-var">showBufMode</span></a></span></span><span> </span><span id="local-6989586621679555531"><span class="annot"><span class="annottext">Buffer e
</span><a href="#local-6989586621679555531"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621679555530"><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679555530"><span class="hs-identifier hs-var">bmo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-777"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679555530"><span class="hs-identifier hs-var">bmo</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-778"></span><span>        </span><span class="annot"><span class="annottext">BufferMode
</span><a href="GHC.IO.Handle.Types.html#NoBuffering"><span class="hs-identifier hs-var">NoBuffering</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;none&quot;</span></span><span>
</span><span id="line-779"></span><span>        </span><span class="annot"><span class="annottext">BufferMode
</span><a href="GHC.IO.Handle.Types.html#LineBuffering"><span class="hs-identifier hs-var">LineBuffering</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;line&quot;</span></span><span>
</span><span id="line-780"></span><span>        </span><span class="annot"><a href="GHC.IO.Handle.Types.html#BlockBuffering"><span class="hs-identifier hs-type">BlockBuffering</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679555528"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679555528"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;block &quot;</span></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showParen"><span class="hs-identifier hs-var">showParen</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; FilePath -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#shows"><span class="hs-identifier hs-var">shows</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679555528"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-781"></span><span>        </span><span class="annot"><a href="GHC.IO.Handle.Types.html#BlockBuffering"><span class="hs-identifier hs-type">BlockBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;block &quot;</span></span><span> </span><span class="annot"><span class="annottext">(FilePath -&gt; FilePath)
-&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; (FilePath -&gt; FilePath) -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#showParen"><span class="hs-identifier hs-var">showParen</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; FilePath -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath -&gt; FilePath
</span><a href="GHC.Show.html#shows"><span class="hs-identifier hs-var">shows</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679555526"><span class="hs-identifier hs-var">def</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-782"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-783"></span><span>       </span><span class="annot"><a href="#local-6989586621679555526"><span class="hs-identifier hs-type">def</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-784"></span><span>       </span><span id="local-6989586621679555526"><span class="annot"><span class="annottext">def :: Int
</span><a href="#local-6989586621679555526"><span class="hs-identifier hs-var hs-var">def</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Buffer e -&gt; Int
forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufSize"><span class="hs-identifier hs-var hs-var">bufSize</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer e
</span><a href="#local-6989586621679555531"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-785"></span><span>
</span><span id="line-786"></span></pre></body></html>